Skip to content

Optimizing the Windows paging file

A long time ago, when RAM began to be cheap enough to stuff more than enough in any of my PCs, I started to systematically completely disable the Windows paging file, with the objective to make sure I never end up swapping. I found this all the more important when switching to SSD, where swapping sure wouldn’t be such a bad performance drag but would wear out the SSD.

However, in Windows 10 (not sure about Windows 7, as I recall at least the issue wasn’t so visible), I noticed that programs would start crashing / refusing to run due to “low memory” way before I reached my maximum capacity. Roughly, with 32 GiB of RAM (which is a large-ish amount, but not as “huge” by today’s standards as when I started using that amount 5 yeas ago), I started getting “low memory” warnings around barely 22-24 GiB of RAM used. What the hell was wrong with Windows so that it seemed to pretend the remaining 8-10 didn’t exist?

There are tons of random advice about swap file / page file management on the Internet, and most provide little justification on their choices. Globally, advice range from “set it to at least 1.5 (or 2) times the size of your RAM” to “you should absolutely disable it“. Which recurrently leads to quite a bit of confusion. The “no page file” arguments have always appeared clearer and more compelling to me (just remove it, see things still work fine, and enjoy no disk writes)… until those mysterious errors.

Eventually, I found the answer: when using RAM, Windows will commit some amount of RAM, larger than what will actually be used. And if there isn’t enough RAM left (including free space on the page file), counting by committed space rather than actually used space, it will fail with this “not enough RAM” error.

From this, my takeaway was that I should add a page file that’s roughly the size of the difference between my real RAM (32 GiB) and the RAM real usage at which I started getting that error (~22-24), so I set it to 8 GiB. With a varying size, since I don’t care about fragmenting that file, since it will +/- never be actually written too, it will just get allocated.
As for your own strategy, I’d say:
– If you don’t care about disk writes (and don’t mind a potential slowness when you start actually using the page file), set it to some high value.
– If you have an HDD and not an SSD, use a fixed-size pagefile
– If you want to minimize disk writes as much as possible, first set no page file, then use your computer normally and see when you start getting that not enough RAM error. Set your page file size to roughly the difference between your total RAM and the RAM actually used at that moment. A bit less if you really want to minimize disk writes as much as possible, a bit more if you want to be sure to be able to use all your RAM, even if it may mean you can have a few disk writes. In the former case, you can probably use a variable-size pagefile even on an HDD. In the latter, hard to decide. Why are you still using an HDD for your OS anyway? ^^

Posted in Windows.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA