Should I disable swap file if I have lots of RAM or should I move it to a virtual RAM drive?

No matter how much RAM you have, you want the system to be able to use it efficiently. Having no paging file at all forces the operating system to use RAM inefficiently for two reasons. First, it can't make pages discardable, even if they haven't been either accessed or modified in a very long time, which forces the disk cache to be smaller. Second, it has to reserve physical RAM to back allocations that are very unlikely to ever require it (for example, a private, modifiable file mapping), leading to a case where you can have plenty of free physical RAM and yet allocations are refused to avoid overcommitting.

Consider, for example, if a program makes a writable, private memory mapping of a 4GB file. The OS has to reserve 4GB of RAM for this mapping, because the program could conceivably modify every byte and there's no place but RAM to store it. So immediately, 4GB of RAM is basically wasted (it can be used to cache clean disk pages, but that's about it).

You need to have a page file if you want to get the most out of your RAM, even if it's never used. It acts as an insurance policy that allows the operating system to actually use the RAM it has, rather than having to reserve it for possibilities that are extraordinarily unlikely.

The people who designed your operating system's behavior are not fools. Having a paging file gives the operating system more choices, and it won't make bad ones.

There's no point in trying to put a paging file in RAM. And if you have lots of RAM, the paging file is very unlikely to be used (it just needs to be there) so it doesn't particularly matter how fast the device it is on is.


You are entirely correct in your assumption.

Memory management algorithms are very complex and by any means not perfect. So swapping occurs even when there is plenty of spare RAM. On some systems, like Linux, you can control swappiness, on others you can't. By swapping out data when there is still plenty of RAM, system in its own way prepares for the situation when it might run out of RAM.

So disabling swapping functionality might give you the improvement in performance because you will only be using RAM which is faster as you already said.

One thing to consider (and you mentioned it already) - you need to have enough RAM to accommodate all the programs you are executing, otherwise you are risking to run out of memory. In this case the performance will drop, some processes may be terminated by OS and system may experience crash/freeze. (read more about it here)

On some machines, especially ones that keep swap file on HDD not SSD, the effect from disabling swapping is very noticeable. On others it is not so obvious. But even if you don't get obvious improvement, think of it in another way, by disabling swapping you will save yourself some disk space on your SSD.

By disabling swapping, you will also prevent memory algorithms from doing unnecessary operation - moving data from RAM to swap and vice versa - in case of SSD this will prevent excessive wear. And in any case this will improve the performance by eliminating unnecessary operations.

Also, read:

  • Windows Swap (Page File): Enable or Disable?
  • https://askubuntu.com/questions/157793/why-is-swap-being-used-even-though-i-have-plenty-of-free-ram

Can you safely disable the pagefile?

If you run out of free memory, including virtual memory, the system cannot continue to guarantee deterministic execution, and ends itself. Before that happens, the operation system will do various other things such as killing programs that use too much memory. What I want to say is, memory is always finite, and every OS can deal with this. Therefore limiting total available memory to 64 GB won't harm Windows - many systems can't go beyond 8 GB even with a pagefile, because with 1 or 2 GB RAM the pagefile is usually a lot smaller than 6 or 7 GB. It should be noted that as long as you have an excessive amount of unused RAM, the overhead of the OS maintaining a pagefile will not be measurable.

Does it make sense to put the pagefile on a ramdisk?

To increase the available memory, most if not all advanced operating systems use some kind of swap file where they take some memory that's in RAM and hasn't been accessed for a while, write the memory to the harddisk (swapfile aka pagefile), and delete the memory from the RAM so that more fast memory is available. The swapfile is used to extend the maximum size of the memory beyond the size of the available RAM.

Therefore, using a ramdisk (which reduces available memory by the size of the ramdisk) to host the swapfile (which increases available memory by the size of the swapfile) will work, but it won't make a lot of sense. It will not offer more memory than disabling the pagefile, yet it will still require the system to run paging algorithms.