1

From linuxatemyram.com:

If your applications want more memory, they just take back a chunk that the disk cache borrowed. Disk cache can always be given back to applications immediately! You are not low on ram!

This isn't true. Something is eating the RAM, and won't give it back. The use case is Chromium or Firefox with lots of tabs, then quit them. There will be additional RAM taken up than before the browser was run.

A few numbers to show what I mean:

On bootup: <2GB used, usually ~1.7GB.

Open a bunch of tabs in FF/Chromium, eventually more than 8GB are used

Quit FF/Chromium, and 3.5GB are used.

What is the 3.5-1.7= 1.8GB? Let's call it X.

Is X a memory cache? A memory leak? Why do both Firefox and Chromium reproduce the exact seem results?

Opening tabs eventually completely fills my 8GB RAM, system freezes, then eventually tabs die/freeze/crash, freeing just enough memory to continue.

The correct function, that I wish Ubuntu had, would be giving whatever the hell X is back to applications when they want RAM to run. However, when I launch an app, and most of the RAM has been eaten up by X, whether it was created by either of the 2 most mainstream browsers, no RAM is reclaimed from X. It remains until I reboot.

Use of "free" and other tools has not helped me diagnose WTF X is.

Any ideas?

Free outputs:

About a minute after quitting chromium.

              total        used        free      shared  buff/cache   available
Mem:        8035708     4037332     2202604     1014656     1795772     2713256
Swap:      12441592           0    12441592

A little while later.

              total        used        free      shared  buff/cache   available
Mem:        8035708     2497680     4168392      552812     1369636     4715280
Swap:      12441592           0    12441592

A day later, moments after a fill up to 7.9GB and all the tabs crash.

              total        used        free      shared  buff/cache   available
Mem:        8035708     5855132      739016     1012864     1441560      923084
Swap:      12441592      975712    11465880

After a similar fill-up and crash.

              total        used        free      shared  buff/cache   available
Mem:        8035708     5777812      638932      714256     1618964     1273920
Swap:      12441592           0    12441592

Some time later, opened chromium, ran it for a few hours (not to max RAM), closed it:

              total        used        free      shared  buff/cache   available
Mem:        8035708      737080     5869896      438592     1428732     6604848
Swap:      12441592      524436    11917156

Right after boot:

              total        used        free      shared  buff/cache   available
Mem:        8035708      689232     6449124      322912      897352     6769772
Swap:      12441592           0    12441592

After Chromium quits:

              total        used        free      shared  buff/cache   available  
Mem:        8035708      967988     5677848      531960     1389872     6284744
Swap:      12441592         336    12441256
  • 2
    I don't see the problem. Yes, firefox and chrome take up ridiculous amounts of ram. However, as explained on the page your link to, closing the program will mark the ram as available, it won't magically make it appear free. But if you now start something else, it will have access to this ram. – terdon Apr 11 '17 at 19:11
  • As I wrote, this RAM is not made available. It will never be accessed. It is taken, and never reclaimed until reboot. – Tom Mercer Apr 11 '17 at 19:21
  • Then please edit your question and explain how you are checking this. How do you check that the memory isn't released? If you close the misbehaving browser and then relaunch it, doesn't it work correctly? Don't you see that the RAM usage remains stable at 3.5 despite opening new tabs etc? Tracking RAM usage is tricky so if you don't explain exactly how you are monitoring this, we won't be able to help. – terdon Apr 11 '17 at 19:49
0

There is no issue as far as I can see. The “available” memory behaves as expected. As applications claim more memory, the available memory decreases; once they quit, the available memory jumps up again.

It's also normal for the system to become sluggish or the user interface to stall entirely while the system accesses the swap space, especially if the device backing it is slow. Hard disk drives are typically worse than flash storage because of their high access latency.

Both Chromium/Chrome and Firefox are known to use lots of memory with lots of tabs open. Either add more RAM to your system or reduce the number of open tabs severely. You may be able to mitigate the issue with a faster swap space backing device.


You can query the virtual memory manager for current memory statistics with free -h (-h is for human-readable number formatting). You can list the (N-1) processes taking up the most memory with ps aux --sort -rss | head -n N or with top and adjusted sorting.

You may also be interested in How do you find out which program is using too much memory?

  • Try to fill up your actual physical RAM with tabs in FF or Chrome. Soon you will start swapping. First, swapping sucks, and system would freeze/hang at the fill-up moment for the physical RAM. I haven't noticed this on 17.10, but haven't tried. Second, fill all your physical RAM with tabs in FF or Chrome. Now quit FF or Chrome. If RAM was released as advertised, everything should go back down to the way it is right after boot. But it doesn't. Something huge just hangs in the RAM, and is never reclaimed or usable. Future uses of Chrome/FF will bump into the physical RAM limit after just 1-2GB. – Tom Mercer Nov 19 '17 at 2:11
  • It happened again today. I just open system monitor and see how much physical RAM and swap file RAM are in use. For example, now, several hours post-freeze I've got 5.0/7.6 physical and 2.8/4.0 swap used. In reality, I'm using about 1GB of RAM. Just a few tabs in chromium. If I had this much Chromium usage on my system immediately post-reboot, it'd be 3.5GB used max. If the system were honoring my swappiness (1) and/or "freeing RAM for applications as necessary", then when I load a few dozen more tabs, the system would make available RAM. But it won't. And it's not. – Tom Mercer Nov 19 '17 at 23:56
  • stress does release memory nicely. the moment it stops, the RAM is released. however, set your swappiness to 1, run stress to fill all your physical RAM + say, 3/4 your swap, then ctrl+c. Notice how the swap remains nearly full? That's bad behavior. – Tom Mercer Nov 20 '17 at 17:29
  • i ran stress for 3.2gb, and initially was at 4.6/7.6(real), 3.5/4.0(swap). after stress and ctrl+c, i'm at 4.6/7.6(real) and 3.7/4.0(swap). This seems wrong. does this happen for you? – Tom Mercer Nov 20 '17 at 17:31
  • @TomMercer: That only bad and silly behaviour about the first case is to set swappiness to 1. The VM still appears to behave as intended in that case. If you think the VM should behave differently please file a bug report at bugzilla.kernel.org and watch it getting closed as WONTFIX. As for the second case, that seems odd indeed. Could you please add the output of free -h and a list of all running processes and their memory consumption? – David Foerster Nov 20 '17 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.