Downsides to disabling/removing swap?

I understand swap is like an extention to RAM and is mostly used when the amount of free memory is below a certain threshold – which can be set with vm.swappiness in /proc/sys/. Swap can also be used for hibernation, like virtual memory on Windows.

I’ve come across this answer which tells a bit more about swap and how it can be used to reduce memory usage, or like disk cache:

Swap is useful because applications that aren’t being used can be
stored on disk until they are used. Then they can be "paged in" and
run normally again. While it is not in memory, though, the OS can use
that memory for something else, like disk cache.

But apart from these, what is swap used for? If I never (theoretically) run out of available memory, and don’t use hibernation, would there be any downsides to having no swap? Would there be any performance improvements? Longer disk lifespan?

Ask Ubuntu Asked by GChuf on November 21, 2021

3 Answers

3 Answers

It is always useful to have some swap just in case you need some extra free memory when memory pressure gets high. Also the kernel will swap out pages that have not been used for a while and this frees up more physical memory for caching file data and this should lead to better I/O performance. Finally, the underlying virtual memory subsystem behaves differently when swap is enabled and this can affect the way the kernel selects processes that need OOM'ing when memory is really tight.

Answered by Colin Ian King on November 21, 2021

If you have enough RAM and never use hibernation, swap is completely useless.

In theory if some RAM pages are sent to swap, there is more RAM available for cache and the most active applications, that can slightly improve performance.

But the process of swapping itself is slow.

If you have enough RAM, or even just enough, it is more useful to install zram-config to improve performace a bit. It will create a compressed swap in RAM.

Answered by Pilot6 on November 21, 2021

When battery in your laptop goes below a threshold, it is hibernated and shutdown. In the process of hibernation, the contents of RAM is dumped into the SWAP partition.


Edit: Post Ubuntu-18.04, Ubuntu automatically creates a swap file in root file system if a separate swap partition is not made.


Answered by turbulence on November 21, 2021

Add your own answers!

Related Questions

How do I install Psiphon on Ubuntu 14.04 LTS (Step by Step)

4  Asked on January 25, 2021 by rahul-raj-rai


How to limit user access to selected applications?

2  Asked on January 25, 2021 by jorrit


kernel panic-not syncing: VFS: unable to mount root fs on unknown block(0,0)

1  Asked on January 24, 2021 by donttakemeseriously


How to torrify the Ubuntu host?

0  Asked on January 23, 2021 by k-madhura-nadh-12a


Mouse work ONLY after suspend

0  Asked on January 23, 2021 by idir


“cannot find -lmpi*” when compiling openmpi code

3  Asked on January 22, 2021 by thomas-ding


Ubuntu functioning as display adapter

0  Asked on January 22, 2021 by richard-boekamp


Ask a Question

Get help from others!

© 2021 All rights reserved.