Preventing Windows from paging some data

I have a large block of data in memory that I don't want Windows to page. The memory is a cache of a section of data that can be reconstructed from files on disk. The cache is meant to completely prevent hard drive accesses as long as enough memory is available, so it's worthless to me if Windows starts paging it. Instead of paging, I would like my application to simply free the memory if required (as mentioned in this post).

Is there any way to allocate a block of memory as non-pagable?


  • VirtualLock() is probably what you are looking for. Raymond Chen has some more info in it here.