Wednesday, May 30, 2012

RAMMap – Freeing up memory

http://technet.microsoft.com/en-us/sysinternals/ff700229.aspx

I found RAMMAP very useful in debugging memory usage scenarios where due to various file operations (copying files around, enlarging VMware Player virtual disks etc) a lot of memory would go into Standy, and then subsequent operations that would require large amounts of what I assume would be contiguous blocks of memory, like archiving large VM images with 7zip, would fail.

From what I understand Standy contains memory pages that were used by the cache manager and they are still kept around in case you might be opening the same file again, instead of reading it off the disk again it can activate it back from standby – it’s also the thing that makes the memory values not add up in Task Manager, as it is counted in both Cached section as well as Available, and Window will free up and zero these pages as needed.

Windows 8 is the first version to show it separately in Task Manager and make things clear:


Back to RAMMap, it shows everything in detail, as explained in this post:
http://blogs.technet.com/b/askperf/archive/2010/08/13/introduction-to-the-new-sysinternals-tool-rammap.aspx

The part that I discovered lately is where RAMMap allows you to empty different sections and gain back some memory – how you can benefit from that? Say you need a large amount of free / zeroed memory or you want to performance test your application and clearing the cache working set or standby would give you a “cold” start.

The “Empty” menu gives you a few different options – if you start from the top and go through the options, it will give you most of the memory back, but you’ll have a slight performance hit as the system will recover. In most cases you might just want to choose the last two, clearing just the Standby lists.


On a 4GB Windows 2008 R2 Server:


The same system after emptying all sections – notice the large amount of free (zeroed) memory.