You are not logged in.

#1 2015-12-28 08:11:52

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Swap usage

Hi,

In this age of gigabyte RAM there's no particular need of swapping. So much I can understand. Still, some applications use swap for some esoteric purposes. What these purposes typically are? Is there a way to tell what apps use the swap right now?

$ free -m
              total        used        free      shared  buff/cache   available
Mem:          11987        3480          84          91        8422        8306
Swap:           511         481          30

Offline

#2 2015-12-28 09:11:08

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Swap usage

Run "smem -kt".

Offline

#3 2015-12-28 09:54:57

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: Swap usage

lucke wrote:

Run "smem -kt".

Thanks!

The swap users are many, almost all of them - KDE and Plasma processes. What are they doing there?

Offline

#4 2015-12-28 10:23:21

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,657

Re: Swap usage

The kernel manages swap, and it will swap out memory pages of processes that are idling and their data seldomly being actively used. And by default it is relatively swap happy so you might want to adjust that https://wiki.archlinux.org/index.php/Swap#Swappiness

Afaik user space processes (like KDE) don't really have a direct correlation with that (apart from allocating more memory than explicitly needed, which can have a myriad of reasons)

Last edited by V1del (2015-12-28 10:41:09)

Offline

#5 2015-12-28 10:38:40

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Swap usage

Processes take memory and some of it isn't used at all - so it gets swapped out sooner or later. Stuff in tmpfs can also get swapped out.

Last edited by lucke (2015-12-28 10:40:40)

Offline

#6 2015-12-28 16:10:34

mpan
Member
Registered: 2012-08-01
Posts: 1,205
Website

Re: Swap usage

Llama wrote:

In this age of gigabyte RAM there's no particular need of swapping. So much I can understand.

Wrong. "Swap is no longer needed" is a myth. Indeed, nowadays swap is rarely needed for purposes it was used a decade ago. But since 10 years ways swap and RAM are used has also evolved.

In 00s and before swap was required because many applications required more memory than was physically available per RAM. Now one rarely encounters tasks that will consume large portion of RAM, let alone need more than a computer provides. However, it's a waste of resources to use it for storing application data in it. Most of the sotware makes use of only a tiny part of their virtual memory. The rest is just lying there idle. Instead of wasting DDRs on doing nothing, modern systems swap out unused data and, instead, use the regained space for other purposes: for example files caching, storing data from tmpfs et cetera.

Hence you should not be disturbed by the fact that your computer is using swap and most of the RAM is free. It's not really free — it just serves goals other than storing apps' data. The only moment you should worry about swap is when it degrades performance or, in considerable way, handicaps responsiveness of your system.

-- edit
Swap also serves as a safety margin against triggering OOM killer too early. It's like a slow-blow fuse for memory.

If you are using SSDs and swap transfers are high (which is not the same as having lots of data in swap), it may be worth disabling swap altogether to decrease wear of the device. OTOH there is a debate on if this is a good idea for developers' machines, where file transfers are very high and it might be a better solution to actually let system swap out unused things and use tmpfs for the building process. Both for performance, security and hardware lifetime reasons.

As Trilby has said below, playing with swappines and other settings is not the best idea and, if you want to avoid things being swapped out, just disable swap completly. While it's not perfect and there is no one-good-for-all golden rule, the configuration is pretty well polished already by people, who spent huge amount of time on exploring the subject. After gaining sufficient knowledge and experience (neither of which I have and you rarely meet persons who do) and squandering lots of time on tweaking and testing, you might squeeze few more percents, but I doubt it's worthwhile.

Last edited by mpan (2015-12-28 16:36:20)


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#7 2015-12-28 16:16:33

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Swap usage

I do not have or use swap at all.  If you don't want your system to use swap, don't bother with 'swapiness' settings, just get rid of your swap partition/file.

My normal use occupies less than 5% of my system's ram.  There is no harm for me in that app data sitting idly in ram* - as otherwise there would be "nothingness" sitting there idly anyways.

But if you do get anywhere near your ram capacity, then allow the system to use swap as designed.


*note: but I don't use KDE/Gnome/any DE/any noteworthy WM.  I start X with a single urxvt instance running tmux and a home-made WM with about 80 loc.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2016-01-02 16:19:31

memory_leak
Member
Registered: 2015-03-02
Posts: 43

Re: Swap usage

I do not use swap either, Haven't used it since I don't know, back in 2008 or so maybe. Never had an issue.

Offline

Board footer

Powered by FluxBB