Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to locate a leak! What does anon mean for pmap?

I'm trying to locate where my memory has gone for a java process running in linux. Someone suggested I use pmap -x to see exactly what the memory is doing.

The output is really long but basically a good portion of it is a repeat of this:

00007fbf75f6a000    1016       -       -       - rwx--    [ anon ]
00007fbf76068000      12       -       -       - -----    [ anon ]

What exactly does this mean? Why do I have so many entries of this (4000+)?

like image 940
erotsppa Avatar asked Sep 25 '09 15:09

erotsppa


People also ask

What does anon mean pmap?

Anonymous memory: Memory not relating to any named object or file within the file system is reported as [ anon ]. The pmap command displays common names for certain known anonymous memory mappings, such as: [ heap ] The process heap.

What is RSS in PMAP?

RSS: resident set size in kilobytes.

What is PMAP in Linux?

The pmap command in Linux is used to display the memory map of a process. A memory map indicates how memory is spread out.


3 Answers

Anon blocks are "large" blocks allocated via malloc or mmap -- see the manpages. As such, they have nothing to do with the Java heap (other than the fact that the entire heap should be stored in just such a block).

In my experience, thread stacks also use anon blocks. If you see a lot of anon blocks that all have the same size, and that size is 512k to 4Mb (the example below is repeated over a dozen times for a Tomcat process that I have running), that's the likely cause. Depending on the program, you may have up to a few dozen of these; if you're seeing thousands, it means you have a problem with threading.

b089f000    504K rwx--    [ anon ]
b091d000     12K -----    [ anon ]
b0920000    504K rwx--    [ anon ]
b099e000     12K -----    [ anon ]
b09a1000    504K rwx--    [ anon ]
b0a1f000     12K -----    [ anon ]

But that leaves a question: why are you using pmap to diagnose a Java memory issue?

like image 84
kdgregory Avatar answered Oct 21 '22 07:10

kdgregory


See this part this part of System Performance Tuning for anonymous memory.

like image 4
Zed Avatar answered Oct 21 '22 07:10

Zed


I've seen that pattern before in a thread leak. If you have code that is trying to pool threads, but somehow messes up and leaks a thread, you get a pattern like that in pmap.

I think each bit of memory is the minimum stack size for the thread, certainly it had nothing to do with heap in our case.
We still got OutOfMemoryErrors when we hit OS limits, even tho when we analise the heap it is not overallocated.

When we had a problem like this pmap [pid] | grep -c 12K turned out to be the number of threads in use.

like image 3
teknopaul Avatar answered Oct 21 '22 06:10

teknopaul