Can I tell Windows not to swap out a particular processes’ memory?

Luca Martinetti picture Luca Martinetti · Jun 24, 2009 · Viewed 9.7k times · Source

Is there a way to tell Windows that it shouldn't swap out a particular processes' memory to disk?

Its a .Net windows service with fairly large memory usage. I got lot of physical RAM but the OS seems to move part of the process memory to the pagefile anyway.

Answer

Eric Petroelje picture Eric Petroelje · Jun 24, 2009

You can use VirtualLock to prevent memory from being paged to disk, but I really think you're better off letting the OS manage the system's memory. It's pretty good at it, and I wouldn't second guess why the OS was swapping things to disk unless I really knew what I was doing.