Despite a good understanding of the underlying principles of memory management, I've never managed to get a decent understanding of what things like SHR in top really mean.
I expect the inconsistencies or unexpected meaning of some of those statistics in top is the primary thing confusing the OP.
Looking at a process in top now I see
VIRT=419MB
RES=11MB
SHR=4.6MB
Looking at the same pid with pmap, I see almost entirely read only mapping, the largest of which is:
Code:
00002b3b6450e000 55084K r---- /usr/lib/locale/locale-archive
That same mapping occurs in other pids.
Since the total of SHR is 4.6MB and that mapping alone is 55MB, obviously that mapping and most of the similar read only file mappings are not SHR.
So is SHR just the resident portion of the shared mappings? That would seem to contradict such documentation as I've been able to find. Or are ordinary read only file mappings not shareable based on some other definition or rule?
Also pmap -x adds a column for RSS and for Anon but puts only '-' in that column. That pid does have resident memory (11MB) and does have anonymous memory (most of which is included in that same 11MB. What do RSS and Anon mean (not mentioned in the man page for pmap)? Is there any way to get decent info on such things (either better documentation on the meaning of the fields displayed by the obvious tools or better tools to display more meaningful stats)?
Also, from general principles of memory management, I know that significant portions of a process's virtual memory are either "demand zero" or "copy on write". To get any decent understanding of the overall memory use in a system you need to know how much is demand zero or copy on write. Some of the sysinternals tools for Windows identify much of the demand zero memory. But I don't know any tools in Linux to identify it or measure it or tell you anything about it.
I expect these are the same questions the OP wants to ask and I hope I'm helping by asking those questions with what I hope are helpful details. (Also I want to know more of this myself).