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: 5770
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: 190
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: 516
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: 516
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: 1270
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: 760
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.


Return to “Other topics”

Who is online

Users browsing this forum: No registered users and 2 guests