LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Early swap usage (https://www.linuxquestions.org/questions/linux-desktop-74/early-swap-usage-4175665243/)

ychaouche 12-01-2019 11:01 AM

Early swap usage
 
Hello.

I'm using Kubuntu 19.10 and noticed that swap was used very early after starting the desktop, even if there's still RAM available (4Gb RAM, KDE Plasma Desktop). How can I troubleshoot what's causing this early use of swap ? isn't swap supposed to be used only if RAM is full ? can I do something about it ?

frankbell 12-01-2019 07:53 PM

What does top or htop tell you about memory usage?

ychaouche 12-03-2019 03:33 AM

Please see imgur album here : https://imgur.com/a/ba7FR6j

syg00 12-03-2019 03:53 AM

Quote:

Originally Posted by ychaouche (Post 6063668)
isn't swap supposed to be used only if RAM is full ? can I do something about it ?

No and no.
Swap is a resource available to the memory management system to manage and balance as it sees fit. Many man years of effort by a bunch of very smart people have gone into the code.
Go find a real problem to worry about. If it really worries you, issue a swapoff/swapon.

ychaouche 12-03-2019 04:02 AM

Ah, this is good to know. The real problem that worries me is the system being slow after some time. I have linked this with swap usage because many times when system becomes unresponsive, I see one or two processes in "disk sleep" state, which means they are waiting for data from disk (could writes also be blocking ? dunno), which is why I thought maybe they are reading from the swap file (since the monitoring tools show swap usage). But after reading your post I assume swap is not an indicator of poor system health.

pan64 12-03-2019 04:39 AM

www.linuxatemyram.com will explain some details.

teckk 12-03-2019 12:14 PM

Code:

cat /proc/sys/vm/swappiness
60

You can change that.
https://wiki.archlinux.org/index.php/Swap#Swappiness

Look at your distros docs.

walker 12-28-2019 03:30 PM

Quote:

Originally Posted by ychaouche (Post 6063668)
Hello.

I'm using Kubuntu 19.10 and noticed that swap was used very early after starting the desktop, even if there's still RAM available (4Gb RAM, KDE Plasma Desktop). How can I troubleshoot what's causing this early use of swap ? isn't swap supposed to be used only if RAM is full ? can I do something about it ?

There's often a misunderstanding about kernel memory paging especially with swap space.

Swap is used always, despite from physical memory in use.
Kernel memory paging put on swap space not often used data despite if ram is full or not.

You aren't anyway using the lightest distro out here, ubuntu and derivatives, since introduction of snapd daemon, waste a bunch of resources doubling already present services and added with the most resources hungry desktop environment.

You have not only to consider the used memory but also the cached memory only the difference between the total memory minus memory reserved for video card+used memory+cached memory is really "in hand" to system i.e. in my system with base 1GB ram right now really free memory is 376MB and it doesn't anyway swap

Quote:

free -m
total used free shared buff/cache available
Mem: 985 427 376 19 181 410
Swap: 2047 0 2047
Maybe your system is to heavy on memory and that's why kernel transfers data to swap.

Eye candies have an high memory price and an high price in system responsiveness too.

I can only suggest you to check with a lighter live i.e. MX Linux which runs smoothly live on my other machine with 2GB ram without swapping.

Let us know.

ludist 12-29-2019 03:44 PM

Quote:

Originally Posted by ychaouche (Post 6063668)
isn't swap supposed to be used only if RAM is full ?

Yes, but this not the default to my knowledge in any distro.

Quote:

swappiness
This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase aggressiveness, lower values decrease the amount of swap. A value of 0 instructs the kernel not to initiate swap until the amount of free and file-backed pages is less than the high water mark in a zone.

The default value is 60.
source, with more RAM details.

Quote:

Originally Posted by ychaouche (Post 6063668)
can I do something about it ?

Yes. Try swappiness 0 or whatever setting suits to your setup / use case.

Code:

echo 10 > /proc/sys/vm/swappiness
root@x2:~# cat /proc/sys/vm/swappiness
10

I have one machine with half RAM than expected (heavy load on ram) and after many failures is working properly with swappiness 10
Code:

sysctl -a | grep swap
vm.swappiness = 10
total      used      free    shared    buffers    cached
Mem:          481        475          6        13          0        68
-/+ buffers/cache:        406        75
Swap:        1023        316        707

After restart, the swap is always used, because the ram is very small.

my light machine is like that
Code:

sysctl -a | grep swap
vm.swappiness = 60
root@x2:~# free -m
              total        used        free      shared  buff/cache  available
Mem:          1504        458        619          83        426        780
Swap:          494        209        285

So, although I have 60 swappiness, since I have plenty of RAM (and light usage) I have less swapped memory.

And my main machine with 6G of ram
Code:

vm.swappiness = 0
23:24:54|503|root@x:~# free -m
              total        used        free      shared  buff/cache  available
Mem:          5883        631        2668        156        2583        4821
Swap:          4479        464        4014

So you can see that the machine with more ram uses more swap, although the setting is to zero. (My main machine operates with many different programs and hibernates to swap).

So probably kubuntu is too heavy and needs swap. You can try 0 setting, but in my stressed machine 10 was the right choice.

I think KDE is a disaster for memory. Only XFCE here for many years. I never worked with KDE the last 10 years.

Quote:

Originally Posted by walker (Post 6072055)
Swap is used always.

To my knowledge this true for Windows, but not for Linux. You can even remove swap with swapoff. This is impossible in windows.

walker 12-30-2019 06:02 AM

Quote:

Originally Posted by ludist (Post 6072368)
So probably kubuntu is too heavy and needs swap. You can try 0 setting, but in my stressed machine 10 was the right choice.

Didn't I write the same?
Giving also a link to a comparison which demonstrates this.

Quote:

Originally Posted by ludist (Post 6072368)
I think KDE is a disaster for memory. Only XFCE here for many years. I never worked with KDE the last 10 years.

I too from a little more. I switched to the true Gnome (2) and when Gnome 3 came switched to XFCE.
Now I use Icewm on my daily driver and JWM for my rescue system installed on a 16GB usb key built upon Devuan minimal live and it run witn fancy transparency too with less than 100MB ram.

I think that reinventing the wheel (Pantheon, Cinammon aso) is a waste of time, and not so smart, when you could instead help to improve what already exists and works.

It seems, too, that the Big Corps. take over of GNU/Linux keep using but formerly getting rid of GNU is also a try to increase hardware requirements hoping to help manufacturers to sell not needed new hardware cause sales are plunging year after year.

My machine with more ram is an eeePC with 2GB ram and with the right OS it works flawlessly also with a 32bit Atom Z520 and I don't use only a browser to surf the net as the large majority do.
My daily driver is an eeePC with 1GB ram and an Atom N455 64bit and my media center used also to watch TV with a DVB/T-T2 usb decoder and watch DVD's is a 2006 IBM T41 32bit 1,4GHZ CPU with 1,5GB ram coupled with a BenQ 32" display.

The will to learn let you save a bunch of money so you haven't to work 24/7 cause money is never enough and in the spare time you can help others, free of charge, to acquire knowledge so they won't be forced to do the beta tester for easy big corps Linux like Canonical IBM\RedHat Suse letting them make money on users' free of charge work.

Quote:

Originally Posted by ludist (Post 6072368)
Quote:

Originally Posted by walker (Post 6072055)
Swap is used always.

To my knowledge this true for Windows, but not for Linux. You can even remove swap with swapoff.

Yes, you can!
swapoff -a will disable every swap space found and mounted on boot but I think we were talking about normal use of an out of the box distro.
But take care that this is no longer true for Ubuntu since 17.04 cause a big corp (Canonical) has decided to replace the swap partition with a swap file resembling Windows.

That's why I avoid fake free software coming from Big Corps and also their, even if community developed (i.e. Mint) derivatives.

Sorry for the, sometimes, OT but it seems that a majority confuse a kernel (Linux is only a kernel useless by itself) with an OS so a little history is sometimes needed.

If you don't like to read cause history is boring... watch it!

Basslord1124 12-30-2019 10:09 AM

As others have said, it's probably KDE. KDE is probably one of the resource hungry of user interfaces. I used to use way back, but haven't used it in many many years. I say change your GUI or if you want to keep using it, I'd recommend upgrading your RAM.

mrmazda 12-31-2019 03:11 AM

Quote:

Originally Posted by walker (Post 6072055)
with the most resources hungry desktop environment.

That characterization apparently may have become obsolete with KDE versions newer than that in Kubuntu 19.10: https://www.forbes.com/sites/jasonev...crown-in-2020/

OP is maybe a candidate to switch to KDE neon.

walker 12-31-2019 04:28 AM

Quote:

Originally Posted by mrmazda (Post 6072755)
That characterization apparently may have become obsolete with KDE versions newer than that in Kubuntu 19.10: https://www.forbes.com/sites/jasonev...crown-in-2020/

OP is maybe a candidate to switch to KDE neon.

I don't trust too much in Forbes & Co. I prefer true amateur site like distrowatch itsfoss aso.

Anyway I've downloaded the latest current (development) Slackware on which is possible to install KDE Plasma 5 so we will see if it's really a KDE trouble or Big Corps Linux without GNU, as I suspect, is defective by design developed with addition of useless daemons and init system injected with binary to follow the road opened by #M$ to bootlick hardware manufacturers to convince them to install their OS's cause they will ensure them a quicker, not needed by normal user, hardware turnover and consequently new hardware sales they won't never had.
i.e. Dell supplies PC with Ubuntu Brought to you by Canonical with Headquarter in the Isle of Man to pay less taxes.

I prefer the true GNU/Linux phylosophy which was recycle instead to toss thanks to GNU/Linux also cause toss still functioning hardware to me it's a crime against environment and it worsen #ClimateChange.

Today I will do some tries.

walker 12-31-2019 04:23 PM

Quote:

Originally Posted by Basslord1124 (Post 6072590)
As others have said, it's probably KDE. KDE is probably one of the resource hungry of user interfaces. I used to use way back, but haven't used it in many many years. I say change your GUI or if you want to keep using it, I'd recommend upgrading your RAM.

Yes!
You, and me, are right.

A 4GB machine is nowadays too weak for Big Corps. Linux maybe they did agreement with hardware vendors, as I suspect, to help them in selling not needed new hardware cause sales are plunging.

A crazy friend give me some days ago a 4 years old 17" HP Laptop with a Core I5 4210U 8GB ram and a 256GB SDD (I keep it as last resort cause I need portability that's why I use old netbooks).
On it he installed Makulu Linux Core derived from Debian so without snapd and all other Ubuntu candies and anyway the bare system as soon as switched on has a memory consumption of 586MB.

On the same machine I had run live AUSTRUMI a Slackware derivative without systemd and Canonical eye candies it runs with 184MB.

It's impossibile to find Kubuntu system requirement and this is not so polite but looking at standard Ubuntu (with Gnome 3) requirements....

Ubuntu Desktop System Requirements

ychaouche is forced to upgrade the ram or switch to a true GNU/Linux distro not bloated with useless services and which wastes ram to load more than once and maybe more than twice the same library only in different version to install with a click statically linked executable.

Sad to say but this is the truth, a machine with 4GB ram which I could use still for years for a newbie or for who follows the herd is an ewaste.

Hope this helped. :(

I'm here to help eventually in choosing and using other to avoid to give away money for a not needed memory upgrade or ever worse to toss a still perfect functioning PC only cause a Big Corp has decided so.

Btw. @ychaouche if you want a KDE out of the box suitable for newcomers give a spin to PCLinuxOS
It has KDE but a minimum memory requirement which is an half of Ubuntu Desktop 2GB minimum instead of 4GB

Let us know!

greencedar 01-01-2020 08:07 AM

I found the information concerning swap in this website helpful in what is going on with swap.

https://www.linuxatemyram.com/play.html


All times are GMT -5. The time now is 07:02 PM.