keepcalculator

06 Numbers and Powers

Disable Swap Partition? When It Makes Sense

Card No. 06·27944 · Updated · Standard formula, shown below

Disabling the swap partition is usually not recommended, but it can make sense on systems with abundant RAM and specific workloads. This article explains what swap does, when disabling it helps, and how to do it safely on Linux and Windows.

What Swap Actually Does

Swap is a designated space on a storage drive that the operating system uses as an extension of physical RAM. When memory pressure is high, the kernel moves less-frequently-used pages from RAM to swap, freeing physical memory for active processes. This prevents out-of-memory (OOM) crashes and allows you to run more applications than your RAM would otherwise support.

Swap is not a replacement for RAM—it is significantly slower because storage I/O is orders of magnitude slower than memory bandwidth. However, it provides a safety net. Even on systems with plenty of RAM, the Linux kernel may swap out idle pages to keep more memory available for file caching, which can improve overall performance.

Why People Consider Disabling Swap

The most common reasons users think about disabling swap are:

  • Performance concerns: If the system swaps frequently, applications stutter and the system feels sluggish. Disabling swap forces everything to stay in RAM, which can help if you have enough memory.
  • SSD wear: Swap writes add wear to solid-state drives. While modern SSDs handle this well, heavy swapping can reduce lifespan over years.
  • Freeing disk space: A swap partition or file can take up several gigabytes. On a small system drive, that space might be more valuable.
  • Misunderstanding: Some believe swap is always bad, thinking it slows everything down even when unused.

These are valid points, but they only apply in specific scenarios. For most users, the risks of disabling swap outweigh the benefits.

When Disabling Swap Makes Sense

Disabling swap is reasonable in a few situations:

  • Large RAM with a predictable workload: If you have 32GB or more of RAM and your heaviest workload uses less than half of it, swap may never be touched. Removing it frees disk space and eliminates any theoretical SSD wear.
  • Real-time or latency-sensitive applications: Audio production, high-frequency trading, or industrial control systems may require deterministic response times. A swap-in event can cause a noticeable delay.
  • Virtual machines and containers: If you run VMs or containers, the host may not need swap because the guest OS manages its own memory. However, this depends on the hypervisor and workload.
  • Testing and development: Developers debugging memory-related issues may want to force OOM behavior to see how their software reacts.

In these cases, disabling swap can be a deliberate, informed choice. But you must be certain your RAM will never be exhausted, because the result of running out of memory without swap is immediate process termination (OOM killer) or system freezes.

How to Disable Swap on Linux

On Linux, you can temporarily disable swap with:

  1. Run sudo swapoff -a to turn off all swap devices and files.
  2. Check with free -h to confirm swap is now 0.
  3. To make it permanent, remove the swap entry from /etc/fstab and delete the swap file or partition (e.g., sudo rm /swapfile).

If you only want to reduce swap usage, you can adjust the vm.swappiness parameter (0 to 100, default 60). Setting it to 10 makes the kernel less eager to swap. To make this permanent, add vm.swappiness=10 to /etc/sysctl.conf.

How to Disable Swap on Windows

Windows uses a page file instead of a swap partition. To disable it:

  1. Open System Properties → Advanced → Performance Settings → Advanced → Virtual Memory → Change.
  2. Uncheck “Automatically manage paging file size for all drives.�
  3. Select each drive, choose “No paging file,� and click Set.
  4. Click OK and reboot.

Windows will warn you that disabling the page file can cause problems. It is generally not recommended, especially because some applications and system components expect a page file to exist.

Risks and Common Problems

The biggest risk of disabling swap is running out of memory. Without swap, the OS cannot gracefully handle memory pressure. The Linux OOM killer will terminate processes—often the one taking up the most memory, which might be your web browser or a critical service. On Windows, applications may crash outright, and the system can become unstable.

Another problem is that some applications (like Java-based tools or certain databases) reserve virtual memory that may never be touched. Without swap, these reservations can fail, even if physical RAM is sufficient. This is a common issue with mmap and memory overcommit settings.

Also, hibernation on Linux requires a swap partition or file large enough to hold the RAM contents. If you disable swap, suspend-to-disk will stop working.

Alternatives to Disabling Swap

If your goal is better performance or less SSD wear, consider these alternatives:

  • Lower swappiness: On Linux, set vm.swappiness=10 to make the kernel use swap only when necessary.
  • Use zswap: This compresses swap pages in RAM before writing to disk, reducing I/O and improving performance without losing the safety net.
  • Shrink swap: Instead of removing it entirely, reduce the size to something small (e.g., 1GB) to handle rare spikes.
  • Add RAM: If you frequently hit memory limits, adding physical RAM is the most effective fix.

These options let you keep the safety net while minimizing the downsides.

How to Decide for Your System

To decide whether to disable swap, answer these questions:

  • How much RAM do you have, and how much do your typical workloads use? Check with free -h on Linux or Task Manager on Windows.
  • Do you ever see swap usage above zero? If not, disabling it may be safe.
  • Do you need hibernation? If yes, keep swap.
  • Are you prepared to deal with OOM crashes if you misjudge? If not, keep swap.

If you are unsure, the safe default is to keep swap enabled but tune it to your needs. Most systems run perfectly fine with a small swap file and low swappiness.

Frequently Asked Questions

Will disabling swap improve gaming performance?

Usually not. Games typically fit within available RAM, and swap is rarely used during gaming. If you have enough RAM, disabling swap won’t change FPS. If you don’t have enough RAM, disabling swap can cause crashes.

How much swap should I have if I keep it?

A common rule of thumb is 1-2 times the amount of RAM for traditional spinning drives, but for modern systems with 8GB+ RAM, a swap file of 2-4GB is often enough. If you use hibernation, you need at least as much swap as RAM.

Can I disable swap temporarily without rebooting?

Yes, on Linux run sudo swapoff -a to disable it until the next reboot. On Windows, you can change the page file settings but a reboot is required to apply them.

What happens if I run out of memory with no swap?

The Linux OOM killer will terminate processes to free memory, often killing the largest memory consumer. On Windows, applications may crash and the system may become unresponsive. This is why swap is recommended as a safety net.

Does disabling swap damage my SSD?

No, disabling swap does not damage an SSD. In fact, it reduces write wear, but modern SSDs have high endurance and swap writes are a tiny fraction of total writes. The difference is negligible for typical users.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →