Swap usage increases until full (memory leak?) [SOLVED]

Hi, everyone. Not sure if I’m in the right section for this post.

I did a fresh installation of Netrunner Rolling on my laptop (Dell Latitude E5510). Mostly everything works fine out of the box, except for swapping.

After a few minutes of uptime, and with only one or two light processes running (sometimes, even with NO processes), swap begins to fill up quickly. It then goes on to increase, without ever being released, until all swap space is taken and the system becomes unresponsive, at which point only logging out and back in can restore it – until the problem starts all over again, that is. :@

The problem shows up unpredictably at some point in the session (but always in a matter of minutes). When swap begins to fill, my KDE desktop immediately gets a bit slower. From this point on, every application started consumes ludicrous amounts of swap space right from the start, until it is full.

What’s particularly puzzling is that the used swap space is not connected to any particular process, AFAIK. It’s just reserved by the system and never released until logout. I have a 5GB swap partition, and also I’m using /dev/zram0-3 (another 2GB), so it shouldn’t fill up so quickly. This is definitely a memory leak.

Has anyone else encountered this bug, or knows how to monitor it, to find what is causing it? I have more than a little suspicion that it’s related to baloo file search, but I’ve tried disabling it, killing it, adding my $HOME to its excluded paths, all to no avail. The problem keeps showing up every time I log in. It’s frustrating, since I have an almost perfectly set up desktop that’s rendered unusable by this memory leak.

System information:

inxi -F

System:    Host: ******* Kernel: 3.10.53-1-MANJARO x86_64 (64 bit) Desktop: KDE 4.14.0 
           Distro: ManjaroLinux 0.8.10 Ascella                                                                               
Machine:   System: Dell product: Latitude E5510 v: 0001                                                                      
           Mobo: Dell model: 09M4GV v: A00 Bios: Dell v: A03 date: 06/02/2010                                                
CPU:       Dual core Intel Core i5 M 520 (-HT-MCP-) cache: 3072 KB                                                           
           Clock Speeds: 1: 1199 MHz 2: 1199 MHz 3: 1199 MHz 4: 1199 MHz                                                     
Graphics:  Card: Intel Core Processor Integrated Graphics Controller                                                         
           Display Server: X.Org 1.15.2 driver: intel Resolution: 1600x900@60.00hz                                           
           GLX Renderer: Mesa DRI Intel Ironlake Mobile GLX Version: 2.1 Mesa 10.2.6
Audio:     Card Intel 5 Series/3400 Series High Definition Audio driver: snd_hda_intel 
           Sound: Advanced Linux Sound Architecture v: k3.10.53-1-MANJARO
Network:   Card-1: Intel Centrino Advanced-N 6200 driver: iwlwifi
           IF: wlp2s0 state: up mac: *********************
           Card-2: Broadcom NetXtreme BCM5761e Gigabit Ethernet PCIe driver: tg3
           IF: enp11s0 state: down mac: *********************
Drives:    HDD Total Size: 2320.4GB (58.7% used) ID-1: /dev/sda model: ST9320423AS size: 320.1GB
           ID-2: USB /dev/sdb model: My_Book_1130 size: 2000.4GB
Partition: ID-1: / size: 38G used: 16G (43%) fs: ext4 dev: /dev/sda7 
           ID-2: /home size: 56G used: 5.6G (11%) fs: ext4 dev: /dev/sda8 
           ID-3: swap-1 size: 5.12GB used: 3.61GB (71%) fs: swap dev: /dev/sda3 
           ID-4: swap-2 size: 0.49GB used: 0.00GB (0%) fs: swap dev: /dev/zram0 
           ID-5: swap-3 size: 0.49GB used: 0.00GB (0%) fs: swap dev: /dev/zram1 
           ID-6: swap-4 size: 0.49GB used: 0.00GB (0%) fs: swap dev: /dev/zram2 
           ID-7: swap-5 size: 0.49GB used: 0.00GB (0%) fs: swap dev: /dev/zram3 
Sensors:   System Temperatures: cpu: 48.0C mobo: N/A 
           Fan Speeds (in rpm): cpu: N/A 
Info:      Processes: 161 Uptime: 2:31 Memory: 1002.9/3757.7MB Client: Shell (bash) inxi: 2.2.1

I’ve never seen this before, why is there four zram swap partitions?
I only have one zram swap partition on all my installed machines, I suspect there is an issue there.
Try removing zramswap:

sudo pacman -R zramswap

The ISO on the site is quite old. have you ran your first update yet?
If not then the first update/upgrade needs to be performed using pacman on the command line and not by using octopi:

sudo pacman-mirrors -g sudo pacman -Syy sudo pacman -S manjaro-keyring sudo pacman -Suu

Answer all questions with [Y]

Hello, AJSlye , thanks for swift reply,

I haven’t used zram before, always had a swap partition. I went with default settings of Netrunner. I will try to remove zramswap and see what happens.

I have run pacman several times since install. I ran your commands again, it tells me the system is up to date.

Sounds good. :slight_smile:

PS. I removed zramswap myself, I found that with it installed and running, my system would swap more often than without it.

Four zram swap devices are normal if your cpu says it has 4 cores. Every core gets a zram swap device to compress stuff to it.

As for swapping out early. That is the preferred way for zram. Swapping out late wouldn’t bring much speed improvements.

For the main problem itself please take a look at all processes in ksysguard to see which application is using excessively the memory. I also am guessing there is a memory leak.

I only removed zramswap from my main DJ laptop as it would cause me issues with Mixxx droping audio and freezing the interface, etc. I still have it running on my other two Netrunner rolling installs.

Now with that said, I have 5 machines ranging from a single core P4 to a 4 core I7 and one AMD 6 core, on a standard default install of Netrunner Rolling, or any of the other 3 Manjaro Editions I have installed I haven’t seen a memory leak, so unless Avonidas has installed something else why would only this one person be experiencing one? Now I do know that until baloo has made it’s initial index it takes some resources but no where near what Avonidas is describing and no where near as long either.
Note: After some reflection I also thought that maybe the memory leek could also be one or all of the zram instances themselves.

A memory leak in zram itself would only show when something is written to it and should be reported before already if it really is an issue with zram itself. It does not explain why the system starts swapping out even when no application (graphical) is running.
I expect baloo or some other application to cause the memory leak. As zram is basically only a swap partition in ram it is highly unlikely that it has a memory leak as it is widely used even if not as widely as normal swap. (All those android devices with version 4.x have zram enabled and many other distributions aswell)
When it comes to preinstalled software firefox + adobe flashplayer are a valid candidate when it comes to memory leaks (especially the flash part).
But the description here seems to be a hint on baloo indexing which is the only thing that can do this out of the box on rolling.
So Avonidas I would recommend disabling the desktop search in systemsettings for now and see if it will produce the problem again.

If it is just the system Indexing your files then I would suggest first giving baloo an hour or so to finish it’s initial index before disabling it. Baloo of course can take more or less time depending on the partition sizes and amount of data on them that has to be Index.


I can confirm the problem re-appears after a while, even after removing zramswap.

Well, that at least explains the 4 zram swaps. :rolleyes:

Leszek, the problem does not seem to be with particular processes, since it crops up with almost anything running. Right now, I see chromium (139MB), plasma-desktop (119MB) and kwin (85MB) are the bulk of memory usage. However, my total RAM usage is at 26% of 4GB, while swap is at 22% and increasing. What I often do as a test is start some heavy process (e.g. Mathematica), then immediately close it. It always takes up more swap, and I can quickly fill it up just by repeatedly starting and stopping processes. Memory is reclaimed, but swap space is not.

I have installed some packages since 1st installation, so I cannot be sure it’s not something I did, but I haven’t done any major changes to the initial system. And the problem first appeared very early.

I have already tried that. I can try it again now, without zram. I’ll let you know how it goes.

[quote]Leszek, the problem does not seem to be with particular processes, since it crops up with almost anything running. Right now, I see chromium (139MB), plasma-desktop (119MB) and kwin (85MB) are the bulk of memory usage. However, my total RAM usage is at 26% of 4GB, while swap is at 22% and increasing. What I often do as a test is start some heavy process (e.g. Mathematica), then immediately close it. It always takes up more swap, and I can quickly fill it up just by repeatedly starting and stopping processes. Memory is reclaimed, but swap space is not.
Do you have all processes shown or only user processes ?
Also do I understand you correctly that only swap space rises and the normal ram usage not ? That would be very strange as normally it should first fill ram until a certain point before swapping out.
Swap Space not being cleared is normal under linux. Either it is used again and gets copied back to ram or it stays there until it is full and then the kernel reclaims the space again for new applications/processes.

Very strange issue, very strange indeed.

All processes.

Yes, ram only rises when I start new processes, and is released as soon as I close them.
The onset of swap “leak” does seem to be related to a certain level of ram usage, but that’s not very high – 20-30% usually. Maybe I should change swappiness level? In any case, that does not explain the constant swelling of swap.

Yes, I know that, but swap is clearly not re-used in my case, or it would be more than adequate with my reported ram usage!

What’s curious is that the slowing down of my system seems to start as soon as any swap is allocated, e.g. while a terminal appears almost immediately after I press Konsole button under normal conditions, when swap begins to fill, I have to wait 2-3 seconds for it to appear. Of course, recently used apps are quicker to respond, but still it’s noteworthy.

Did you check the MD5SUM on the ISO you downloaded?

When it is swapping heavily it writes a lot to harddisk and that makes those apps unresponsive (blame completely fair I/O scheduler for it)

But in general it is very strange that swap keeps filling even if the applications are closed.

The default swappiness in Rolling is the kernels default 60. So normally it should only think about swapping out stuff if it reaches 60% or higher.
One exception would be an ultra large page that wouldn’t fit into normal ram early on and it than would use swap.
But I can’t imagine which default application could do this.

Maybe it is akonadi. Could you try stopping akoandi from its configuration gui or with akonadictl stop command.

Netrunner Rolling like it’s upstream Manjaro, all kernels use the BFQ I/O scheduler by default not the CFQ I/O Scheduler.

I’m not sure why akonadi would be causing this, but it is worth a shot to disable it, just remember to re-enable it if that’s not the cause.

Yes, it matched. But I can’t imagine a faulty ISO would have let me finish the installation and boot into a working system, anyway.

akonadictl stop Akonadi is not running.

Okay, since the bug has gone away after I’ve upgraded the kernel to 3.16.2-1, and hasn’t reappeared for some weeks now, I decided to mark this as [SOLVED]. I still have no idea what caused it, though… :huh: