.netwindowsmemorypagefile

Disabling swap (paging file) to ensure everything is really in memory


I have several applications that need real memory, and they consume a lot of it. One solution would be to have every piece of memory inside application LOCKED (VirtualLock) but it would require many hours to do right, since apps are in .NET.

So, my question is, is the DISABLING the swap file (I have PLENTY of RAM on the machine) valid strategy to ensure that everything will really be in memory?

Update:

Let me repeat - I know that this might be very DIRTY way of doing things, and may break operation of the whole OS, but, I'll take full responsibility and cope with consequences, would just want to know what I might run into, problem-wise.

Here's what other StackExchangers think about it: https://serverfault.com/questions/23621/any-benefit-or-detriment-from-removing-a-pagefile-on-an-8gb-ram-machine


Solution

  • There is one thing that you cannot force into memory by doing that: Executable images and mapped files. Those are a each "page file" of their own. When memory pressure occurs Windows detects that their pages in memory have not been modified and just discards those pages because they can be reloaded later.

    Everything that is not file-backed cannot be paged out (there is just no place to put it). So I guess your technique would work in practice.

    You won't see a lot of problems. I am running without paging file all the time (16GB RAM). You loose the ability to capture full memory dumps in case of a blue screen but most likely you don't need that.

    Just make sure that you never hit the physical memory limit or else a lot of programs will crash hard. Nobody writes their programs to cope with OOM situations (except core Windows components which I never have seen crash from that. Good job by them.).