views:

110

answers:

4

I need to prevent application's memory pages from being swapped out of RAM on Windows. Is there a WinAPI function equivalent of POSIX mlockall() to achieve that?

A: 

Hi you can set the windows option of lock pages in memory. Usually this setting is mostly used by SQL Server, but works also for other applications. Check this site on msdn

enable addressing windows extensions (AWE) for your application. See this link on msdn

pipelinecache
+6  A: 

Yes, VirtualLock(). There's a limit on how many pages you can lock, you can't hog RAM. Details are in the MSDN article.

Hans Passant
A: 

You can try http://gnuwin32.sourceforge.net to (try to) avoid porting, in case this is what you are doing.

Vinko Vrsalovic
+1  A: 

I have to ask, why do you need to do this? If every app thought its pages were so important that they shouldn't be paged out ever, it would be a giant waste of memory.

If the pages are in use, they won't be sent to the pagefile, and if they're not in use, why keep them around? Trust in Mm, it was written by a very smart guy :)

Paul Betts
It is true for most applications, but I am writing a very specific application where I need to be guaranteed not to incur latency from page faults.
Alex B
Can you elaborate? Maybe we can give you a better answer if you describe the scenario more...
Paul Betts
dude! Windows is NOT a realtime OS. The latency from pagefaults is going to be small compared to the many many other sources of latency and interruption on the system.
Chris Becke
Luckily, I just need it for some testing.
Alex B