Ubuntu Linux: Process swap memory and memory usage
The linux virtual memory system isn't quite so simple. You can't just add up all the RSS fields and get the value reported used
by free
. There many reasons for this, but I'll hit a couple of the biggest ones.
When a process forks, both the parent and the child will show with the same RSS. However linux employs copy-on-write so that both processes are really using the same memory. Only when one of the processes modifies the memory will it actually be duplicated.
This will cause thefree
number to be smaller than thetop
RSS sum.The RSS value doesn't include shared memory. Because shared memory isn't owned by any one process,
top
doesn't include it in RSS.
This will cause thefree
number to be larger than thetop
RSS sum.