Windows Server: Prevent process swapping/paging

memorypagingswapvirtual-memorywindows-server-2008

Is there a possibility to prevent swapping for a single process?
This process is an in-memory-database and should not be moved to virtual ram.

all other processes should still be swap-able.

I need something like the "lock pages in memory" option of the SQL-Server.

Best Answer

If a process starts swapping, it's either very poorly coded and not releasing RAM when it should or your server doesn't have enough RAM available to handle all the tasks it's currently performing and you should expand the RAM capacity.

If that's really not an option budget-wise or if the machine is already at maximum RAM capacity, you could schedule a task that kills and restarts the process every hour or so (or more frequent if needed). Note that this should really be a last-resort and temporary solution, as it's not really so much of a solution, but just a work-around.

As for the core of your question, there is no way that I know of to prevent a program from swapping. It's basic OS behaviour when a process runs out of physical memory to use to prevent your machine from crashing.

Related Topic