SWAP partition is not always necessary on a modern Linux PC.
SWAP partition is not always necessary on a modern Linux PC.
I consider myself a fairly advanced Linux user. I understand potential risks but have taken precautions to avoid issues. Restricting the number of processes, avoiding fork bombs, setting RAM limits, and adjusting the user's niceness level so root can recover if the system becomes unresponsive are all measures in place. Linux offers a wide range of capabilities—just imagine what you can achieve. You can control CPU allocation for specific programs and more.
I believe many think swapping is mainly for conserving RAM. That idea was likely valid in the past when memory was measured in smaller units, but it wasn't always the case. Even then, if things became unstable and swapping increased heavily, the system would likely be struggling and could crash soon. This assumption isn’t accurate. Swapping still helps relocate apps and their data that aren’t actively used, freeing up space for other purposes like file system buffers. In everyday use, you probably won’t notice much difference, but having swap space is beneficial. It can also improve performance in certain scenarios—especially if you run applications using a significant portion of your RAM at once. If you prefer not to rely on default settings, you can tweak swappiness in Linux to better match your needs. Remember, consider your specific requirements and allocate enough memory accordingly. Swap is generally a helpful addition, even with ample RAM; it’s just a small adjustment that can enhance efficiency in edge cases. As @jpenguin noted, having swap makes sense if you plan to use hibernation as well. See the Ubuntu FAQ for more details on why swap can be advantageous.
My hands-on experience with swapping on both Windows and Linux shows a drastic drop in performance compared to simply running out of RAM. When memory runs low and swap is inactive, the OOM killer quickly terminates processes using the most memory available until your programs fit back into the limited space. This usually happens instantly, freeing the system with minimal delay, though you’ll likely lose whatever was in progress. With swap enabled, the system becomes unresponsive every time it needs to use it, often requiring a hard reboot once free space appears. On Windows, this can lead to complete freezing and frequent hard restarts, whereas on Linux, I sometimes have to disable swap entirely to avoid such issues. The trade-off between speed and stability is clear in my usage.
This situation has been discussed frequently online. It's happened to me too, though it was about a decade ago on Linux. I seem to rely on more reliable programs now—they tend to have fewer memory issues. The most recent crash due to a leak occurred roughly 8 to 10 years prior, while I was playing Blobwars: Metal Blob Solid. It had a problematic bug (incompatibility with certain libraries) that led to a significant memory leak—about 500MB in just 10 seconds. At the time, I likely had around 1GB of RAM.