Do i need swap?

Ok, this is what I know…

When Linux was first written “640K is more memory than anyone will ever need”. So, now days 8Gb really is more than most systems need. Yes, there are exceptions to that rule, but most of them have to do with WinBlows.

The thing that Swap is mostly used for in Linux is, RAM dump on crash for debuging. Or save state on Hibernation, as others have noted.

The short answer now days is “No”. With the caveat emptor that if your system uses RAM dump or hibernation, then “Yes”… at about 2Gb disk for each 1Gb RAM.

2 Likes

So when the system runs out of RAM, swap is not necessary used as a form of temporary RAM?

1 Like

Put a swap on your system and log how often it’s used (assuming you don’t have RAM dump or hibernation).
If you have a bloated system… live wallpaper, widgets and doodads all over your desktop, 30 or 40 tabs/windows open at one time… yeah, your going to need RAM/swap, and lots of it.
Or you could run a cleaner distro/desktop interface. I still have systems around here with 4Gb of RAM, running Lubuntu, and hardly ever dig into swap. (admittedly I don’t play modern games on 4Gb, but I still do HTML5 games on Firefox and that’s know to have problems eating up RAM)

Even if you do run out of RAM, it will just bottleneck until some frees up, and that’s usually not much worse than the bog-down from swap.

P.S. Thanks for reading and understanding my whole post, not just pulling one line out and reading it out of context.

I think Manjaro is a popular os for Linux-gamers, in such a situation I think swap might be something such user needs even with 16GB with certain games. Anyway I should test this myself (I have a swap partition).

Even if you do run out of RAM, it will just bottleneck until some frees up, and that’s usually not much worse than the bog-down from swap.

I wonder if that still applies when using an ssd.

1 Like

I did a test a few months back…bored as hades.

First, even outside of this test, I have all my compiling set up to use /tmp.

The time it took to complete this test was irrelevant…the purpose was to fill 32GB of RAM and crash the system.

Firefox…20 tabs.

Put my entire $HOME/.cache in RAM (using ASD)

Compile linux 5.8.0RC1 simultaneously with:

glibc 2.31 and

gcc 10.1

At no point did I exceed 27GB.

So, for my daily use, swap [file,partition] is unnecessary/unneeded.

Sure, but probably not as pronounced as when swap is on a spinner. It still takes time to do the actual work.

2 Likes

Hi !
I ALWAYS setup swap, whichever RAM size. even with an aggressive swappiness, attempting to maximize RAM use, I see suff in my swap.
Here an exemple with a long session, 3 Firefox profiles with lots of tabs, Gimp, Shortwave & pulseeffect :

[meuh@ordi1 ~]$ free
              total       utilisé      libre     partagé tamp/cache   disponible
Mem:          11756        4772        3987         574        2996        6099
Partition d'échange:         255          60         195
[meuh@ordi1 ~]$ 

But, as I don’t know if it’ll be used and what size I should set, I use systemd-swap.
To optimize it, I create a file : /etc/systemd/swap.conf.d/overrides.conf
Where I add to default setup :

swapfc_enabled=1
swapfc_min_count=1
swapfc_chunk_size=512M

In short, it creates a first 512Mo temp swapfile that can be complemented by as many other as needed.

My setup : Sujet: Optimiser la gestion de la RAM et du Swap sous Linux | l'Almanet doLys de nam1962 et ses amis (clic on the flag to have the english translation)

:wink:

5 Likes

To use Zswap you need a swap partition/file. Zswap - ArchWiki

3 Likes

What I do is using a swap file, and let it scale as needed.

1 Like

I am still new in this. And now I am confused…what is the best solution than ?

To make swap partition during the installation or what ?

Use systemd-swap It’ll take care of itself as said on #4

1 Like

There is rarely such a thing as the best solution. It always depends on what you want to do, then some solution can be helpful to achieve your goal. The same solution can become a hinderance in other cases.

1 Like

Interesting. I have 32 GB as well, with a 500 MB swap file. I do see some swap use from time to time in a ballpark of tens of megabytes, with swappiness set to 20. And I haven’t used the system for anything memory intensive since I installed Manjaro about three months ago :thinking:

Personally, I think swap needed when compiling from AUR or from source code.

https://pasteboard.co/Jnp5rUf.jpg

1 Like

Nothing special… I have 6 gb ram which is shared with graphics card…I just want smooth multitasking, browsing and gaming (only fm20). Most of the time while I am using chrome, few tabs opened, laptop slows

Can I use swap partition and systemd-swap together ?

To quote from the arch wiki link given earlier in this thread:

In order for systemd_swap to be effective you need to remove any traditional swap devices you have.

2 Likes

Oh thanks, I missed that…so to be sure, while installation, for swap partition I need to choose none ? And when installation is finished, only use systemd-swap ? Thanks

Hi, I just installed fresh KDE on my laptop.

I wanted to try setup systemd-swap but I stucked on step : creating a file /etc/systemd/swap.conf.d/myswap.conf

How to do that ? In Dolphin I can not open etc folder as root ?thx

It’s all described in the wiki:

sudo bash -c 'echo -e "zswap_enabled=0\nzram_enabled=0\nswapfc_enabled=1" > /etc/systemd/swap.conf.d/myswap.conf'

https://wiki.manjaro.org/index.php?title=Swap

2 Likes