OS suddenly starts trying to transfer everything from RAM to swap

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help
AnnaR
Level 1
Level 1
Posts: 5
Joined: Fri Jul 28, 2017 7:36 am

OS suddenly starts trying to transfer everything from RAM to swap

Postby AnnaR » Fri Jul 28, 2017 8:42 am

Hello everyone! :D
I've been using Linux Mint for several years now, but never needed to post anything before. I'm not a computer expert, but have acquired some basic familiarity with how Linux works by now.
Recently, I've been having this strange issue and have no idea how to even go about diagnosing it. It happens only sporadically and seemingly totally at random. The OS just suddenly starts transferring all it can to the swap space, almost emptying the RAM for no obvious reason. The mouse moves very very slowly during that time, applications are very slow to start or respond and the sound of the harddrive being written to becomes very loud. When I finally manage to reach a terminal and type swapoff, the letters are not slow to appear though.
I don't know how far it would go if I were to let it continue, since I need to use my computer for my work and I really don't like that sound so I always stopped it via the swapoff command. If my memory usage is too high for it to be able to transfer everything back to RAM, it tells me that it can't deactivate the swap for this reason, but the swapping stops and I can use my computer again. If it can transfer everything back, it does so, but more slowly than usual I think.
I set my swappiness parameter quite low, now 7, quite some time ago since I have only 3.6GB of RAM and with the default settings it was swapping too often. Now it usually begins using the swap space when it gets to around 3.0GB or so, and most of the time works ok.
Does anyone have any idea what the reason might be, or what I could check to find out? Is it a bug that I should file under the bug reports or is it specific to my computer somehow?
My system: Old Novatech laptop. Several partitions with data and OSs kept separate. The swap space changed since installation, but I updated fstab with the new UUID.
Linux Mint 17.3, 64-bit, Cinnamon.

User avatar
Pierre
Level 15
Level 15
Posts: 5784
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby Pierre » Fri Jul 28, 2017 8:51 am

run this command in Terminal

Code: Select all

top

and note which programs are using the most resources.
do try to check, both when the machine is running normally,
& when it is showing that error, if possible.

Note - - that it's a moving report, so just watch what is just below the white bar.
if you can, post a screen_shot of that - - back here.
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.

AnnaR
Level 1
Level 1
Posts: 5
Joined: Fri Jul 28, 2017 7:36 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby AnnaR » Fri Jul 28, 2017 12:39 pm

Hello Pierre, thanks for the quick reply.
I actually have the System Monitor on almost constantly these days and check the Processes tab quite often, to check if Firefox has grown too large or other processes are using a lot of RAM, since I have such a small amount of RAM that can get filled up quite quickly.
The first time this issue occurred, I did check the processes and did not see anything obvious that might be causing it, and the processes there were not the ones occupying the CPU. That's why I suspect the problem to be with the operating system itself, I think it started happening since the last time I updated it.
Anyway, if it happens again I'll take a screenshot, it might be a few days though.

syg00
Level 3
Level 3
Posts: 197
Joined: Fri Jul 21, 2017 4:00 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby syg00 » Fri Jul 28, 2017 10:54 pm

Doesn't make any sense. If the swapoff works, you have enough RAM. Almost sounds like it's going into hibernation. Are you actively using the laptop when all the disk activity starts ?.
Next time it happens, and before running anything else (especially the swapoff), run this from a terminal - post the file here.

Code: Select all

cat /proc/meminfo > meminfo.txt

AnnaR
Level 1
Level 1
Posts: 5
Joined: Fri Jul 28, 2017 7:36 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby AnnaR » Wed Oct 11, 2017 11:09 am

So typical, three times it happens over a not too long period, then I go and post about it and it stops happening for a while. I had the command ready in a terminal waiting to catch it for quite a long time, but now was starting to think that maybe the problem had somehow fixed itself and was getting lax with the readiness. Three months later it finally happens again and I was caught unprepared. I tried opening the tab with this forum thread as I couldn't quite remember the command, but it wouldn't load at all and then Firefox just crashed.
After some time, I finally managed to bring up the System Monitor and took a screenshot of the Processes tab, attached here. It's ordered so that highest CPU usage is at the top. Like I was saying, there is no obvious programme or process visible there that might be the culprit, at least not obvious to a non-expert like me. Tixati is a torrent client, seeding in the background, it's normal that it uses a little RAM like this.
Then I tried opening a terminal, but everything was responding so slowly that while I was still typing, suddenly the swapping stopped and my computer was seemingly back to normal. Except that there was only 1GB of data left on my RAM and 1.6GB on the Swap. So here is the meminfo from that instant right after it stopped, and the second attachment shows the Resources tab of the System Monitor also from right after.
MemTotal: 3788464 kB
MemFree: 2422096 kB
MemAvailable: 2585148 kB
Buffers: 51640 kB
Cached: 258480 kB
SwapCached: 157912 kB
Active: 177128 kB
Inactive: 810428 kB
Active(anon): 120392 kB
Inactive(anon): 566408 kB
Active(file): 56736 kB
Inactive(file): 244020 kB
Unevictable: 16 kB
Mlocked: 16 kB
SwapTotal: 4095996 kB
SwapFree: 2408264 kB
Dirty: 24 kB
Writeback: 0 kB
AnonPages: 636380 kB
Mapped: 160380 kB
Shmem: 9356 kB
Slab: 93108 kB
SReclaimable: 62464 kB
SUnreclaim: 30644 kB
KernelStack: 9216 kB
PageTables: 31692 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 5990228 kB
Committed_AS: 5245952 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 54336 kB
VmallocChunk: 34359650196 kB
HardwareCorrupted: 0 kB
AnonHugePages: 104448 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 469504 kB
DirectMap2M: 3461120 kB

User avatar
Minterator
Level 5
Level 5
Posts: 519
Joined: Thu Jan 10, 2013 8:29 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby Minterator » Wed Oct 11, 2017 4:02 pm

Linux starts swapping when it runs out of memory, otherwise it will crash. Perhaps you do need more ram?

My laptop has only 4GB ram and NO swap partition, that's an option.
Mint 17.3 MATE

AnnaR
Level 1
Level 1
Posts: 5
Joined: Fri Jul 28, 2017 7:36 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby AnnaR » Wed Oct 11, 2017 5:09 pm

Well yes, but it is supposed to only swap out as much as necessary, and most of the time it does that. But on these rare occasions, it suddenly goes crazy and transfers way more than necessary. With a swappiness parameter of only 7, there really is no reason why it should leave only 1GB on a 3.6GB RAM.
The laptop is pretty old and initially came with only half as much RAM. There are no more free slots now to add more. And doing completely without a swap partition is no option either, since it gets used most of the time. It's mostly Firefox that eats loads of memory, I've already limited the cache but I read that the adblocker bloats its memory usage a lot. But after getting used to having an adblocker, there's no going back to looking at stupid ads again!

User avatar
Minterator
Level 5
Level 5
Posts: 519
Joined: Thu Jan 10, 2013 8:29 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby Minterator » Wed Oct 11, 2017 6:41 pm

I even run a Windows virtual machine without problems, but firefox is memory hog, you could try Chrome. Also check "system monitor" processes, you may have another memory hog in the background. You could try without swap partition, or a swap file instead.
Mint 17.3 MATE

rene
Level 6
Level 6
Posts: 1275
Joined: Sun Mar 27, 2016 6:58 pm

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby rene » Thu Oct 12, 2017 6:24 am

I would feel that "Tixati" torrent client you speak of the most likely suspect. "Feel" and "most likely" rather than more definite terminology since fairly little can be said from over here. The promised screenshot was not attached -- but I'd expect it to not be very useful anyway so don't overly bother. As far as I can see there's little of note in your /proc/meminfo; certainly the value that stands out most is the huge VmallocTotal -- but that's actually precisely 32 GiB and is the same on this 4 GiB system that I'm typing on; is apparently not a usefully reported value. "Commited_AS" (5 GiB) may otherwise be most relevant here but would on the other hand and at best seem to confirm what you said already.

That is, basically just guessing, but having said that: If your torrent client gets or seeds a few huge files it would be specific to the client how this translates to mapped memory; how much it preallocates or reads in advance respectively. Especially if both early and late bits of the same huge file come in at the same time this might mean the entire file is preallocated -- which might then in turn upset the memory-pressure logic in the kernel.

So does this happen only ever while that torrent client is running? If yes, I'd try a different client. Seems "Tixati" is not from the repositories? I'd simply use the standard Transmission client, even if only to test if you have some issue with it..

Neil Edmond
Level 5
Level 5
Posts: 765
Joined: Thu Dec 26, 2013 10:19 am
Location: N.E. AR USA

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby Neil Edmond » Thu Oct 12, 2017 8:09 am

AnnaR wrote:I read that the adblocker bloats its memory usage a lot.
Which do you use? I've found uBlock Origin to be better on my systems in that area than what I was using before.

Petermint
Level 4
Level 4
Posts: 274
Joined: Tue Feb 16, 2016 3:12 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby Petermint » Tue Oct 24, 2017 12:25 am

My 4 GB machine runs Firefox, Thunderbird, and a heap of other applications in 2 GB. Firefox has only Noscript added, which blocks all the Javascript junk before the "JS hits the fan".
Some applications appear small then open a dozen other tasks all chewing memory. Cinnamon is currently using 368 MB and has over 20 other tasks loaded.

lmintnewb2
Level 4
Level 4
Posts: 357
Joined: Sat Apr 07, 2012 5:23 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby lmintnewb2 » Tue Oct 24, 2017 1:01 am

Sounds like you've dorked around with vm settings, what's set in /etc/sysctl.conf ? Can't remember off the top which exact config's would be involved but stuff like vm.dirty_ratio and vm.dirty_background_ratio, do remember configs like this when they hit their limit will block everything and dump to disk. Messing around with such config's is a know what you're doing proposition. So if you've customized such settings and weren't having issues prior, perhaps remove the affected modifications and see how you system performs.

Lowering swappiness is a given/must imo ... high or low-spec hardware ( well esp for personal computing gnu/Linux users), monkeying around and modifying vm settings w/o a real understanding of the consequences or what someone is doing ... not so much. Don't doubt they can be used to improve performance based on usecase but atm, have only ever researched it and generally leave most vm (virtual memory) management up to the installed kernel, other than swappiness anyway.

Would be of the opinion that any modifications set in sysctl.conf fall under that same category. Know what you're doing and why kinda thing. Could also check in terminal what's the output of "cat /proc/sys/vm/dirty_background_ratio" believe it's normally set to a value of 10 and "cat /proc/sys/vm/dirty_ratio", normally set to value of 20.
The most powerful free tech-support tool the world has ever known. > HERE <

Petermint
Level 4
Level 4
Posts: 274
Joined: Tue Feb 16, 2016 3:12 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby Petermint » Tue Oct 24, 2017 2:14 am

I looked in my LM 18.2 /etc and could not find a dirty anything setting. Based on https://lonesysadmin.net/2013/12/22/better-linux-disk-caching-performance-vm-dirty_ratio/:

Code: Select all

$ sysctl -a | grep dirty
sysctl: permission denied on key 'fs.protected_hardlinks'
sysctl: permission denied on key 'fs.protected_symlinks'
sysctl: permission denied on key 'kernel.cad_pid'
sysctl: permission denied on key 'kernel.unprivileged_userns_apparmor_policy'
sysctl: permission denied on key 'kernel.usermodehelper.bset'
sysctl: permission denied on key 'kernel.usermodehelper.inheritable'
sysctl: permission denied on key 'net.core.bpf_jit_harden'
sysctl: permission denied on key 'net.ipv4.tcp_fastopen_key'
sysctl: permission denied on key 'net.ipv6.conf.all.stable_secret'
sysctl: permission denied on key 'net.ipv6.conf.default.stable_secret'
sysctl: permission denied on key 'net.ipv6.conf.enp0s25.stable_secret'
sysctl: permission denied on key 'net.ipv6.conf.lo.stable_secret'
sysctl: permission denied on key 'net.ipv6.conf.wlp2s0.stable_secret'
sysctl: permission denied on key 'vm.mmap_rnd_bits'
sysctl: permission denied on key 'vm.mmap_rnd_compat_bits'
vm.dirty_background_bytes = 0
vm.dirty_background_ratio = 10
vm.dirty_bytes = 0
vm.dirty_expire_centisecs = 3000
vm.dirty_ratio = 20
vm.dirty_writeback_centisecs = 500
vm.dirtytime_expire_seconds = 43200
sysctl: permission denied on key 'vm.stat_refresh'

User avatar
catweazel
Level 10
Level 10
Posts: 3133
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby catweazel » Tue Oct 24, 2017 2:31 am

Petermint wrote:I looked in my LM 18.2 /etc and could not find a dirty anything setting.

The instruction to the OP wasn't to look in /etc for anything dirty. It was:

Code: Select all

cat /proc/sys/vm/dirty_background_ratio

The command associated with the request for the contents of a file in /etc is:

Code: Select all

cat /etc/sysctl.conf
Mint Donor #6036
If your problem is fixed, please mark your thread as [SOLVED] by editing the title of the first message in the thread.

Petermint
Level 4
Level 4
Posts: 274
Joined: Tue Feb 16, 2016 3:12 am

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby Petermint » Tue Oct 24, 2017 3:58 am

what's set in /etc/sysctl.conf ?

The only things mentioned in /etc/sysctl.conf are net.ipv4 stuff and all that is commented out. What is /etc/sysctl.conf for?

The following suggests systemd has changed things: https://wiki.archlinux.org/index.php/sysctl

User avatar
catweazel
Level 10
Level 10
Posts: 3133
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: OS suddenly starts trying to transfer everything from RAM to swap

Postby catweazel » Tue Oct 24, 2017 4:02 am

Petermint wrote:What is /etc/sysctl.conf for?


> goes to go-ogle
> types in What is /etc/sysctl.conf for?
About 411,000 results (0.59 seconds)
> reads first summary link...

sysctl is an interface that allows you to...
Mint Donor #6036
If your problem is fixed, please mark your thread as [SOLVED] by editing the title of the first message in the thread.


Return to “Other topics”

Who is online

Users browsing this forum: No registered users and 3 guests