Flushing the Windows Disk Cache

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.

After running 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.

9 thoughts on “Flushing the Windows Disk Cache”

  1. Thanks. Last night I would have used it, but today flushmem.exe suits my purposes better. (Consume.exe spews windows over my desktop and is intended more for testing programs in low-memory situations.)

  2. hi Chad,

    I was desperately looking for a tool to flush my system cache as it was causing a database server that i was using (Interbase) to become unresponsive on Windows 2003 Server. I landed upon your page and tried the flushmem.exe and it works great. Thanks for the same.
    The only question I have for you is, is there a way to prevent flushmem from consuming all of the CPU memory while it is running? Any help on the same will be very helpful. Thanks for the utility.

  3. Dear Chad,
    I have a 2009 Gateway that came with Vista but I changed it to xp pro about a year ago. It has 4gb ram and 500 gb HD. All was fine but I’m into home recording and I notice that sometimes the computer would hiccup during either recording or playback. I downloaded and ran flushmem.exe thinking this would help. I also unloaded a lot of stuff from my start up folder. But now I cant run open office from Oracle even though the program is on my computer. It shows up in programs listing and windows explorer. Also I’m missing my windows msconfigin file. All programs downloaded run fine. Do you think I messed up my registry with this flushmem.exe? Any help possible? Thank you. Charlie Niel

Leave a Reply

Your email address will not be published. Required fields are marked *