How to maximize the memory usage of a single Windows process

pagefilepagingswapswappingwindows-server-2008

I have a system with a large amount of memory. Right now, to prevent a single application from paging, I've disable the paging file completely. The issue that I'm running into is that I cannot maximize memory usage for the single process I care about. I want to disable paging for a single process so that it never pages out, and it can use most (95%?) of the memory; all other process should be able to page out. Right now we end up using ~%80 of the available memory with the disabled paging file, but we know that we don't care about those processes being sent to the paging file. This is not an open-sourced program that I'm running, so I cannot modify the code to use other .NET/Windows calls to prevent the paging myself.

I think on Linux this is called "swappiness".

Best Answer

You can't tell the O.S. to keep a process data in memory; the process can do it itself if it has the "lock pages in memory" right, but it must request it explicitly in code; otherwise, Windows will page out as it deems appropriate.

If you completely disable the page file, Windows will just reserve some memory for itself, and will start to deny memory allocation requests when too much memory is already in use.

If you leave the page file enabled (as you really should), you have absolutely no control on what and when will be paged out.

Anyway, you should have better trust in the memory manager: its job is to page out unused/unneeded data, and if a process is actively accessing its memory there are very little chances it will be paged out. Unless, of course, memory usage is so high that the system just can't cope with it; but if this is the case, then you really should look into adding more memory to the box.