This is a utility designed for testing the behaviour of OS X's virtual memory system as memory is allocated and de-allocated by applications.
The "Allocate" button (at the bottom) allocates the specified number of megabytes - but it doesn't use that memory. I.e. it doesn't write anything to that memory. This allocated memory adds to the total VM (virtual memory) of this process but it doesn't change the amount of RAM used by this process. Note that the "VM" reported by the 'top' utility is the sum of the VM's of all processes, so the total "VM" for the machine (not shown in this application) will go up when the VM for this process goes up. No matter how much memory you allocate using this button, the "Swap Total" (showing the amount of disk space used by swap files) should not change (unless it changes due to some other program's activity).
The "Allocate and Use" button allocates the specified number of megabytes and then writes data to that memory. The application will read from this memory every 15 seconds so that the OS will continue to see this memory as being used. This allocated memory adds to the total VM (virtual memory) of this process and (since it is used) adds to the RAM used by the process. If you allocate enough memory, you will see the "Swap Total" grow as the OS swaps out some of the memory contents to disk.
The system and program info is updated every 5 seconds and several hours worth of the data is stored so that you can go back and look at the state of the system at an earlier time.
Holding down the Option key when you click on the arrows at the top makes it jump by 10 intervals for each click. Note that you can click and hold on the arrow buttons to scan through an interval of time. Holding down the Option key makes this go faster.
You can export the data by using the "Export..." menu item in the "File" menu. The data is exported in a comma-separated format that is easy to import into Excel for example. The first line in the file supplies a legend indicating the meaning of each of the comma-separated fields.
This application was partially inspired by Shawn Erickson's "Memory Muncher" app.
download the VMTester executable (version of Sept 2012)
download an older version of the VMTester executable (Nov 2006, PowerPC only)
download the VMTester project files (licensed under the GPL)
(Requires the Apple Developer Tools - I used XCode version 3.1.3)
This project illustrates several aspects of programming for Mac OS X using the Cocoa API:
- use of NSTableView data sources & notifications
- use of an NSMutableArray to create a "ring buffer"
- use of applicationShouldTerminateAfterLastWindowClosed
- using a "sheet" for error notification and for simple dialogs
- use of NSTimer (to get regular updates)
- use of NSTask (to run a shell command)
- detecting modifier keys (Option key) on button clicks