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) ?