Configure memory manager to minimize memory fragmentation
28 February 2006 by Snakefoot | Comment » | Trackback OffAll applications uses memory, and while running they can make different requests to the memory manager (VirtualAlloc / VirtualFree):
To monitor if the virtual memory has become fragmented, one can use Perfmon and Add Counters... from the Process Performance Object. Select the counters Virtual Bytes and Private Bytes for a certain process (*Hint* Notice the Explain button). If Virtual Bytes grows much larger than Private Bytes over time, then it can be an indication that memory fragmentation is happening. If Virtual Bytes is much larger than Private Bytes at application start, then it can indicate that the application just reserves virtual memory at startup. If Private Bytes (VM Size in Windows Task Manger) grows continuously, then it can indicate that the application has a memory leak.
It is possible to change the behavior of the memory manager, so instead of performing the decommit right away, then it will only decommit when it there is a contiguous memory block of a certain size to decommit. This change in behavior will lower the chance of memory fragmentation, but will also generate a memory overhead, and should only be considered if having more than 1 GByte RAM, and having problems with virtual memory fragmentation.
More Info MS KB Q325044
More Info MS KB Q815372
- Commit memory, when the application wants to allocates more memory for its own use
- Reserve memory, when the application wants to reserve a contiguous block of memory without allocating physical memory
- Decommit memory. when the application wants to change committed memory to reserved memory (Release physical memory)
- Free memory, when the application wants to release committed/reserved memory so other processes can use the memory address space instead
To monitor if the virtual memory has become fragmented, one can use Perfmon and Add Counters... from the Process Performance Object. Select the counters Virtual Bytes and Private Bytes for a certain process (*Hint* Notice the Explain button). If Virtual Bytes grows much larger than Private Bytes over time, then it can be an indication that memory fragmentation is happening. If Virtual Bytes is much larger than Private Bytes at application start, then it can indicate that the application just reserves virtual memory at startup. If Private Bytes (VM Size in Windows Task Manger) grows continuously, then it can indicate that the application has a memory leak.
It is possible to change the behavior of the memory manager, so instead of performing the decommit right away, then it will only decommit when it there is a contiguous memory block of a certain size to decommit. This change in behavior will lower the chance of memory fragmentation, but will also generate a memory overhead, and should only be considered if having more than 1 GByte RAM, and having problems with virtual memory fragmentation.
More Info MSDN (Managing Virtual Memory in Win32)[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Control \Session Manager]
HeapDecommitFreeBlockThreshold = 262144 (Default = 0)
More Info MS KB Q315407
More Info MS KB Q325044
More Info MS KB Q815372
Tags:
Category:
Updated: 15 May 2007