Occasionally, I want to test the performance of a program after a cold boot, or maybe after the computer has been idle for hours and the program has been paged out. For example, the IMVU client starts relatively quickly when the disk cache is warm, but at system boot, it can take quite a while for the login dialog to even appear. Iterating in these situations is a pain in the butt because you have to reboot or leave your computer idle for hours.
I'm sure there exists a program which will flush the disk caches and force programs out of memory and into the page file, but I can't find it. So I wrote one.
First, a caveat: programs these days rarely handle out-of-memory situations, so running
flushmem.exe might cause open applications to explode like popcorn. Buyer beware, etc.
flushmem.exe, you should find that your computer becomes painfully slow as applications are paged back into memory and the disk cache is refilled. Perfect. Now I can realistically simulate the experiences of our users.
You can download the program here or on the FlushMem page.
Implementation details: in Windows, each process has a 2 GB user mode address space limit by default. If physical memory + page file size is greater than 2 GB, flushmem spawns multiple processes. Each process allocates memory in 64 KiB chunks until it can't anymore, and then writes to each page, forcing older pages out to the page file.