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

X.LINK
  • 2,448

1 Answers1

2

You can find the RAM used by every process for all users with the following command:

ps -eo pid,command,rss,user

That gives, in order, the process id, command, the memory used, and the user of the process.

If you want the total amount of RAM being used by all of the processes, the the following command will work

free

If you want a SUM of the memory being used by every process, use the following code:

ps -eo rss | awk '{sum+=$1} END {print sum}'

That will give you a value which is the total amount of memory being used by all of the processes.

Nasir Riley
  • 1,564