4

I'm having a RAM problem where my RAM is full but there's nothing consuming al of it. The sudo htop commands shows my real memory usage, while sudo gnome-system-monitor shows the memory full. It wouldn't be a problem but the system actually thinks it's full so it closes Firefox tabs, and I can't open other VMs.

It's worth noting that I use VMs but they are stopped. Maybe when I stop there's a bug in KVM which does not free the VM memory. Right now I have a VM with 15GB RAM + Firefox on the host machine with lots of tabs. It should be taking 19GB as said by htop.

I'm using Ubuntu 22.04. This wasn't happening in 21.10 and 21.04

enter image description here

Firefox keeps closing my tabs thinking the PC is using all the RAM, but it isn't. I can't work!

Rafaelo
  • 145
  • 1
    The total size of your RAM 33.4 GB and the relatively high system load makes me think you have the kernel module zram enabled. Is it enabled? … as this might explain what is going on with your RAM. – Raffa Jun 06 '22 at 06:19
  • 1
    Also, do you have any configured tmpfs or RAM disk/s ? – Raffa Jun 06 '22 at 06:33
  • @Raffa lsmod | grep ram is empty – Rafaelo Jun 06 '22 at 10:58
  • @Raffa take a look at my update – Rafaelo Jun 06 '22 at 10:59
  • Ballooning? Yes … please see: https://serverfault.com/questions/780098/why-doesnt-memory-consumed-by-balloon-driver-not-show-up-in-top – Raffa Jun 06 '22 at 11:33
  • @Raffa it wouldn't be a problem if I firefox did not keep closing my tabs when the memory is "full" – Rafaelo Jun 06 '22 at 11:37
  • It’s not just FireFox … the other web browsers keep tabs in memory too … so no memory, no tabs … How much physical memory installed? 34 GB really? Have you allocated some to the GPU in the BIOS if you have such feature or is there involved some sort of memory compression/management software/module? – Raffa Jun 06 '22 at 11:55
  • @Raffa this just happens when the memory is "full", which is after I open the android emulator. It's 32gb ram + swap, I did not allocate anything – Rafaelo Jun 06 '22 at 14:14
  • htop reading seems correct then, but AFAIK htop doesn't count all memory reserved/consumed by kernel unless it is explicitly used by a certain process which is not how ballooning really works ... 33.4 GB shown in system monitor is most likely affected by this ballooning thing, the same total RAM miscalculation happens with Zram ... so all in all I would say memory ballooning is the culprit in your situation ... probably disable/limit it and see if the readings of the two apps come close to each other. – Raffa Jun 06 '22 at 14:41
  • Ballooning functionality relies in part on the guest OS reporting how much memory it actually used and what memory pages can be reclaimed/recycled by the host OS … that’s why problems might appear with one guest OS and not other guest OSs … l suggest you set the maximum and minimum usable memory to the same value for that Android VM thus, sort of, disabling ballooning for that specific VM and see how things go. https://pmhahn.github.io/virtio-balloon/ – Raffa Jun 06 '22 at 15:49
  • @Raffa shouldn't the balloon pop when I close the Android VM though? It stays there, this is the problem – Rafaelo Jun 06 '22 at 18:36
  • 1
    It should in ideal situations but, things like this (a different virtualization solution) may happen on both sides guest/host probably due to user configuration or unsupported driver … What I suggest here, however, is just an educated guess based on your observation and feedback … but, only you can troubleshoot, isolate and confirm the cause as you have already done 50% of that by isolating the android VM … now concentrate your troubleshooting on that to find precisely what element is to blame/exclude :) – Raffa Jun 07 '22 at 04:16
  • See this story for a possible reason for your Firefox tab closing. – user68186 Jun 30 '22 at 19:52
  • @user68186 ok, but I'm actually using like 12gb of RAM and firefox is already closing tabs but my computer has 32gb of RAM – Rafaelo Jun 30 '22 at 19:55
  • I don't know enough about this issue but I have been following it here I don't know for sure if this is your problem. – user68186 Jun 30 '22 at 19:58

1 Answers1

6

You are not comparing the same things. Your graphical display is showing cached memory, which always tends to eventually appear full with linux, and your numeric display is showing what memory is actually available if recoverable caches were dropped which they will be if the memory is needed. Example, notice how the cache size changes after I ask the system to delete them:

root@s15:/home/doug# free -m
               total        used        free      shared  buff/cache   available
Mem:           15724         407         152           5       15163       14983
Swap:          16085         132       15953
root@s15:/home/doug# sync
root@s15:/home/doug# echo 3 > /proc/sys/vm/drop_caches
root@s15:/home/doug# free -m
               total        used        free      shared  buff/cache   available
Mem:           15724         407       15139           5         176       15062
Swap:          16085         132       15953
Doug Smythies
  • 15,448
  • 5
  • 44
  • 61
  • 2
    but I'm getting tab closes on firefox, and I can't open 2 vms with 12gb each. This never happened before and the memory always followed what I had open. How can I stop the firefox tabs from closing? – Rafaelo May 21 '22 at 15:18
  • Output of journalctl -xe after a crash would be helpful to see if any OOM (out of memory) errors are occurring. You can do sudo journalctl -xe > output.txt to create a file output.txt containing the logs, then upload to Pastebin and edit your question to provide a link to that. – Jivan Pal Jun 09 '22 at 09:36
  • 1
    @Rafaelo Do you mean Firefox tabs closing without you doing nothing? Maybe is related to this feature/bug – Pablo Bianchi Jun 10 '22 at 18:29