Tools like 'ps' and 'top' report various kinds of memory usages, such as the VM size and the Resident Set Size. However, none of those are the "real" memory usage:
- Program code is shared between multiple instances of the same program.
- Shared library program code is shared between all processes that use that library.
- Some apps fork off processes and share memory with them (e.g. via shared memory segments).
- The virtual memory system makes the VM size report pretty much useless.
- RSS is 0 when a process is swapped out, making it not very useful.
- Etc etc.
I've found that the private dirty RSS, as reported by Linux, is the closest thing to the "real" memory usage. This can be obtained by summing all
Private_Dirty values in
However, do other operating systems provide similar functionality? If not, what are the alternatives? In particular, I'm interested in FreeBSD and OS X.