Why Debian is not using swap as it should, and computer gets really slow when RAM is full or almost full?
DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've only 4G on my RazPi. I use a lightweight WM (XFCE) and it's generally ok. With Zoom under box64, a lot of libs are processed and held in ram, and I need 6G. Does your swap show in df -h? If not, it's not mounted, or might be puny. Here's how I made my swap file
Pick some file or just touch one
dd if=/dev/zero of=swapfile bs=100M count=2048
mkswap swapfile
swapon swapfile
Then enter it in /etc/fstab. htop is also good for memory stats.
Last edited by business_kid; 04-08-2023 at 07:59 AM.
:lol: No, the 'G' didn't print, & I didn't notice, it should read 4GB, (now corrected)....
I see. So, it has a fairly good amount of memory. Probably the same as the computer with the problem here.
But you are (possibly) using the "bad unity" of measure, that conflicts with the International System of Units (ISU). See what i said in the #8 post, in this thread.
Since you are using something derived from Debian, i think you will have the same "details" in the free command. It is a bit offtopic for the thread, but i think it has its importance. Do a few commands to see, show us, and i show you my output here, in the good computer:
$ free -h # Use the shorter 3 digits unity closer to each value
total used free shared buff/cache available
Mem.: 15Gi 10Gi 2,1Gi 1,7Gi 3,0Gi 3,3Gi
Swap: 15Gi 717Mi 15Gi
$ free -b # Use bytes (B) unity for all values
total used free shared buff/cache available
Mem.: 16690577408 11274518528 2184806400 1822777344 3231252480 3547979776
Swap: 17082347520 751828992 16330518528
$ free --si # Use I.S.U. units
total used free shared buff/cache available
Mem.: 16299392 10915508 2215820 1792592 3168064 3547052
Swap: 16681980 734208 15947772
$
See the difference? If we use letters k, M, G, T, etc. to count computing related things, there is ambiguity. And companies use this "detail" to sell us less than we think. To buy, we receive a "16 gigabytes" (I. S. U. things) memory. But what it really has is actually "15,544 gigabytes" (1024 power), or correctly writing and saying: 15,544 GiB or 15,544 gibibytes (fifteen gibibytes and five hundred and fourty for thousandths ).
So you're using 1 Gig of ram and have 1.5 Gig free besides caches and that's why there's no swap usage. Linux is very efficient with memory. Until I got box64, I never used swap on my RazPi.
The Pi is really slow - period. Arm have much better 64 bit cores than the A-72, but they must be overpriced, so everyone doing things on the cheap gets the A-53 or A-72. Firefox sucks also. Palemoon or Chromium are better.
Last edited by business_kid; 04-09-2023 at 05:05 AM.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
All I'm reading here is that a computer with less RAM is becoming slower than one with more RAM once the swap starts to be used. Isn't that to be expected? Surely the one with less RAM has more of the current, in use, programs and data in swap so finds it slower to access those?
When I have experimented with filling RAM to see what happens (I have no swap) I find that once RAM is full the machine does not slow down it simply starts killing programs to free RAM for the "most important" so I don't think a lack of memory in and of itself causes slowness just the actual inability to use as much RAM.
I use slarm64, not debian. Debian for Pi gets mixed reviews, and you don't get answers. Run 'df-h', 'sensors', and 'free -h' again when it's very slow and post results. Debian just don't care. It's not their distro.
Also run htop. You can see where memory & cpu are being used. If it's overheating, the Pi can slow drastically, and switch cores off, which affects performance.
If you want to try slarm64, there's a forum here under distributions and a RazPi 3&4 thread with links to the binary images. It's my choice of the Slackware Arm ports.
Last edited by business_kid; 04-09-2023 at 09:43 AM.
Not sure what this will prove, but here they are, (I normally use free -m, so have included it also).
Code:
keith@msi:~$ free -m
total used free shared buff/cache available
Mem: 3730 1028 1524 265 1178 2194
Swap: 255 0 255
keith@msi:~$ free -h
total used free shared buff/cache available
Mem: 3.6Gi 1.0Gi 1.5Gi 265Mi 1.2Gi 2.1Gi
Swap: 255Mi 0B 255Mi
keith@msi:~$ free -b
total used free shared buff/cache available
Mem: 3912134656 1078628352 1597992960 278691840 1235513344 2300465152
Swap: 268431360 0 268431360
keith@msi:~$ free --si
total used free shared buff/cache available
Mem: 3820444 1068460 1545344 272160 1206640 2231420
Swap: 262140 0 262140
(This is with Firefox having been running for several hours.)
And beyond what business_kid said, 'free' says that 1,2Gi are being used with buffer or cache. So, it says, in the last column of your output, you have 2,1Gi available. Is my interpretation of the free output correct, business_kid? (or anyone who wants to say this)
Now, about the comparison of using ISU or not, the difference (in absolute byte numbers) is bigger for bigger numbers. See this "table" with 3 columns and several lines:
Code:
IS unit 1 B = 1 byte
Wrong unit (should be) 1 B = 1 byte
Difference (using ISU) 0 B = 0 bytes
IS unit 1 KiB = 1* 2^10 bytes = 1.024 bytes
Wrong unit (should be) 1 kB = 1* 10^3 bytes
Difference (using ISU) +24 = 24 = 24
IS unit 1 MiB = 1* 2^20 bytes = 1.048.576 bytes
Wrong unit (should be) 1 MB = 1* 10^6 bytes = 1.000.000 bytes
Difference (using ISU) +48.576 = 49 KiB = 49kB
IS unit 1 GiB = 1* 2^30 bytes = 1.073.741.824 bytes
Wrong unit (should be) 1GB = 1* 10^9 bytes = 1.000.000.000 bytes
Difference (using ISU) +73.741.824 = 73 MiB = 73MB
IS unit 1 TiB = 1* 2^40 bytes = 1.099.511.627.776 bytes
Wrong unit (should be) 1TB = 1* 10^12 = 1.000.000.000.000 bytes
Difference (using ISU) +99.511.627.776 = 99 GiB = 99GB
So, when we buy a disk with "1TB" of space, you may be thinking you are getting almost 100 GiB more than what it actually has!
And when you use the argument "-m" for free, you are always getting numbers being showed in MiB. They are in ISU mibibytes. So, the number of bytes of each number you see, should be obtained when you multiply it by 2^20 (which is 1 MiB). Is this clear?
All I'm reading here is that a computer with less RAM is becoming slower than one with more RAM once the swap starts to be used. Isn't that to be expected? Surely the one with less RAM has more of the current, in use, programs and data in swap so finds it slower to access those?
When I have experimented with filling RAM to see what happens (I have no swap) I find that once RAM is full the machine does not slow down it simply starts killing programs to free RAM for the "most important" so I don't think a lack of memory in and of itself causes slowness just the actual inability to use as much RAM.
No. Not expected to the point it is happening here. No program was ever killed (the browser keeps running, ever for days, as i have tried a few of the first times this happened; and it would be the first one that would be killed, i think). And its disk is not so slow.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
Quote:
Originally Posted by dedec0
No. Not expected to the point it is happening here. No program was ever killed (the browser keeps running, ever for days, as i have tried a few of the first times this happened; and it would be the first one that would be killed, i think). And its disk is not so slow.
But using swap is slow - remember that unless you're not using that disk for anything but swap it's also being used by other processes and that the speed of swap is levels of magnitude slower than RAM.
The fact you're not seeing processes being killed means you're not exhausting your swap and RAM, and the system is behaving as it should, it's just the swap you are using is slowing your system.
I use slarm64, not debian. Debian for Pi gets mixed reviews, and you don't get answers. Run 'df-h', 'sensors', and 'free -h' again when it's very slow and post results. Debian just don't care. It's not their distro.
Also run htop. You can see where memory & cpu are being used. If it's overheating, the Pi can slow drastically, and switch cores off, which affects performance.
If you want to try slarm64, there's a forum here under distributions and a RazPi 3&4 thread with links to the binary images. It's my choice of the Slackware Arm ports.
You are not saying this to my problem, right? But the other situation cited above, for comparison, correct?
But using swap is slow - remember that unless you're not using that disk for anything but swap it's also being used by other processes and that the speed of swap is levels of magnitude slower than RAM.
The fact you're not seeing processes being killed means you're not exhausting your swap and RAM, and the system is behaving as it should, it's just the swap you are using is slowing your system.
No. It does not make sense. During the slowness periods, there is no other process making much use of RAM or disk or swap - if any, since they are so little. And the slowness is a lot stronger than I have seen years ago when (for example) using a computer with 32MiB of RAM run a game that recommends 512MiB or more. 4GiB of RAM, today, is something common. The hardware of the computer good i have been calling good is probably worse than the other.
My "disk of bad" here has a lot of free space (around 213GiB). The swap is huge (64GiB, and it is never used, i barely see it in the system monitor graph, seen all the time), so the system should (probably should, this is a guess, a thought of mine) not worry to split data to store into smaller pieces, to fit into fragmented space, or moving data to make free space have bigger continuous areas.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
Quote:
Originally Posted by dedec0
No. It does not make sense. During the slowness periods, there is no other process making much use of RAM or disk or swap - if any, since they are so little. And the slowness is a lot stronger than I have seen years ago when (for example) using a computer with 32MiB of RAM run a game that recommends 512MiB or more. 4GiB of RAM, today, is something common. The hardware of the computer good i have been calling good is probably worse than the other.
My "disk of bad" here has a lot of free space (around 213GiB). The swap is huge (64GiB, and it is never used, i barely see it in the system monitor graph, seen all the time), so the system should (probably should, this is a guess, a thought of mine) not worry to split data to store into smaller pieces, to fit into fragmented space, or moving data to make free space have bigger continuous areas.
OK, so if swap isn't the problem a way way to confirm this is to turn off swap and make full use of the RAM and see whether it slows then. If it doesn't slow in that case then it is something to do with swap and if it doesn't then it's not.
I'm seeing posts here which is crazy. @decdec0, the dictionary is the only place you see 'success' come before 'work.'
sure windows slows. Magazines write about windows, but we're fixing a linux problem. Linux is very well designed. I had a chance to obseve my 3.7G being overloaded. It filled up to 3.4-3.5G, and then started filling swap. I'll bet you're not using swap.
It could be: Chips overheating; dodgy disk partitions; a kernel problem; a very slow network; library incompatabilities, to name just a few. You won't try anything, so how do we know? Check those areas out. Don't waffle but give us information in short diagnostic posts.
I'm seeing posts here which is crazy. @decdec0, the dictionary is the only place you see 'success' come before 'work.'
sure windows slows. Magazines write about windows, but we're fixing a linux problem. Linux is very well designed. I had a chance to obseve my 3.7G being overloaded. It filled up to 3.4-3.5G, and then started filling swap. I'll bet you're not using swap.
It could be: Chips overheating; dodgy disk partitions; a kernel problem; a very slow network; library incompatabilities, to name just a few. You won't try anything, so how do we know? Check those areas out. Don't waffle but give us information in short diagnostic posts.
Right. Thank you for this list.
I will try this starting list, for now. I have already checked how to disable swap, I will just prepare a few details to avoid losing anything, in the case of the system killing running programs.
A problem of very slow network should not be the problem, I think. The network for these 2 computers is the same: both connected with a cable to the same modem (and it receives data with a coaxial cable, from the network company). I would see the slowness in the other computer, I think.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.