1
I do face the same hangs like this post: https://askubuntu.com/questions/41778/computer-freezing-on-almost-full-ram-possibly-disk-cache-problem
To sums up: looks like prefetched/cached/paged RAM reclaiming takes too long, so I live in constant fear that the disk makes insane disk readings to the point that the PC hangs and forces me to reboot.
So I've digged more into this problem and got that useful command :
sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
Which do drop the prefetched RAM... up to a point since there's still some left, which seems to be a "static" part.
I've noticed that adding this to the prefetchless RAM usage matches top's used RAM.
However, this doesn't tell me how much "static" prefetched RAM I'm using. And knowing this will let me give enough time to Linux's paged cache offloading to do its job when I'll be about to reach the total RAM count.
E.g: Cache was ~1000 MiB, then got to ~700 MiB after doing "echo 3 | sudo tee /proc/sys/vm/drop_caches"; the ~700 MiB are the "static" part of the prefetched RAM that I need to know.
So my question is: How do you get the -real- "static" part of the Prefetched/Cached/Paged RAM usage ?
PS:
On the other hand, is there a way to only output the total RAM used by every processes -even root's ones- (like htop's mem value) ?
Doh, sorry if I wasn't clear. By "all the RAM", I meant the total RAM used by every processes. – X.LINK – 2018-01-12T17:58:23.680
1See my edit above – Nasir Riley – 2018-01-12T19:25:05.730
It did showed the total amount, but there's other outputs too. I could grep that, but I need a single -and only- output so I can do some repeating math without using too much resources. What's more apriopriate would be how free get that value internally, but I unfortunately don't know how to code. So there must be another way to get such numbers. – X.LINK – 2018-01-12T21:10:20.140
1I have added another edit. – Nasir Riley – 2018-01-12T21:39:46.057
I'll be damned, by replacing "%mem" by "rss" you've got me on the right path for the whole answer. What the RSS total shows is the real memory usage without the "dynamic" part of prefetched RAM, and neither top's "used" or neither htop's RAM nonsense values ! Thanks ! – X.LINK – 2018-01-13T05:46:33.637
No problems. I've updated my answer with rss replacing %mem as it is more fitting your question. – Nasir Riley – 2018-01-13T13:42:42.660