- 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.
- Private Bytes - The total amount of memory (RAM + pagefile) requested by the process.
- Working Set - Total physical memory (RAM) used by the process
- Virtual Bytes - The virtual address space occupied by the process
Microsoft introduced a new heap implementation called low fragmentation heap (LFH) with Windows XP / 2003 (Back ported to Win2k SP4). If developing an application that is very memory intensive, then one can activate the LFH HeapSetInformation(), instead of creating a home built memory allocator. The LFH uses fixed sized buckets so small and large allocations are not mixed together, but at the cost of higher memory usage because the buckets introduces slack. More Info MSDN - Low-fragmentation Heap MSDN - Heap: Pleasures and PainsThe Task Manager in Windows 7/2008 has the following important columns:
- Working Set (Memory) - Physical memory used by the process, includes memory shared with other processes (DLL's etc.)
- Memory (Private Working Set) - Physical memory used by process alone
- Commit Size - Virtual memory used by the proces, includes RAM and pagefile (Private Bytes)
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 KB315407
More Info MS KB325044
More Info MS KB815372
Leave a Reply