2

Can a Linux swap partition be too big?

I'm pretty certain the answer is, "no" but I haven't found any resources on-point, so thought I'd ask.

In contrast, the main Windows swap file, pagefile.sys, can be too large. A commonly cited cap is 3x installed RAM, else the system may have trouble functioning.

The distinction seems to lie in the fact that Linux virtual memory is highly configurable with kernel parameters, not to mention compile options, whereas Windows virtual memory is barely so. Windows virtual memory management consequently seems to rely on algorithms that are immutable or seem to rely on swap file size and how it is configured.

Linux has its own virtual memory management algorithms, of course, but the question is whether and how they are affected by the size of the specified swap partition or file.

This comes up because I have a system with 16GB physical RAM configured with a series of 64GB partitions to facilitate a multi-boot capability. For convenience / laziness, I've simply designated one of these 64GB partitions as swap, i.e., 4x physical RAM in contrast to Windows' 3x cap (the latter being relevant only as a frame of reference because this is a Linux-only system). I'm debugging some issues around memory management and VMware Workstation and have come to wonder what, if any, effect the swap partition's size has on compaction, swappiness, page faults, and performance generally.

Many thanks for any constructive input.

1
  • A commonly cited cap is 3x installed RAM, else the system may have trouble functioning. - citations needed. 99% of people out there who have enough RAM do not need SWAP at all. I've been running swapless both Linux and Windows for over 15 years now. Had 0 problems because of that. Most people continue to misunderstand why and when it's needed. SWAP generally has bad effect on pretty much everything, and more often than not it makes system behavior very erratic and unpredictable. It should only be enabled when absolutely needed. Aug 23, 2022 at 22:36

1 Answer 1

3

Seeing articles like this disturbs me although I haven't researched the issue enough to confirm their conclusions. Having an overly-large swap partition on Linux will not cause any performance problems. Swap is used as necessary and can be somewhat controlled by swappiness. The amount of swap space allocated is never considered in the algorithms for swapping (or paging) out processes. The biggest consideration is that if you have to start swapping your performance is going to drop considerably. Any system that relies on swapping needs to have more physical memory installed.

1
  • It has been my take as well that Linux memory management is fully configured with kernel options, including swappiness, and that swap space size do not affect virtual memory management, but thanks for the confirmation.
    – ebsf
    Aug 24, 2022 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.