Using pmap and its options


pmap a command we can use to find out process entire memory usage,including stack,heap,data segment parts.

$pmap PID

Here we have -x option to find memory allocation with
amount of resident, non-shared anonymous, and locked memory.

MEMORY LEAKS:

$pmap -x PID|grep heap will give us memory leaks information about a process.

If we are running another instance of process and heap size continues stable state means, we conclude that our process doesn't have any memory leaks.

Example: pmap for process(man).

$pmap -x 16556
16556: man man
Address Kbytes RSS Anon Locked Mode Mapped File
00010000 32 32 - - r-x-- man
00028000 8 8 8 - rwx-- man
0002A000 24 24 24 - rwx-- [ heap ]
FF200000 1208 1208 - - r-x-- libc.so.1
FF33E000 40 40 40 - rwx-- libc.so.1
FF348000 8 8 8 - rwx-- libc.so.1
FF360000 64 64 64 - rwx-- [ anon ]
FF380000 8 8 - - rwxs- [ anon ]
FF390000 24 24 24 - rwx-- [ anon ]
FF3A0000 8 8 - - r-x-- libc_psr.so.1
FF3B0000 208 208 - - r-x-- ld.so.1
FF3F0000 8 8 8 - rwx-- [ anon ]
FF3F4000 8 8 8 - rwx-- ld.so.1
FF3F6000 8 8 8 - rwx-- ld.so.1
FFBFA000 24 24 24 - rw--- [ stack ]
-------- ------- ------- ------- -------
total Kb 1680 1680 216 -

-------------------------------------------------------------------------------
The above example taken with assumptions:Solaris 10, some prior solaris versions may incluede Private memory data also. Its just Anon size on soalris 10.

The Private[prior versions] Memory size or
Anon[solaris10] sizes is per process instance wise, and not shared memory sizes[shared libraries and executables].