Monday, January 25, 2010

Using Mustang's jmap/jhat to profile GlassFish

clipped from
The Source for Java Technology Collaboration

Using Mustang's jmap/jhat to profile GlassFish

I decided to ping Alan to make sure he wasn't aware of any socket leak, and he recommended I try the improved jhat. I was a little scared of using this tool, and I wasn't sure if I should use strace/truss instead.....I was very very surprised by the new Mustang's jhat. Since then, I can't live without it :-). What I did is:

% jmap -dump:file=heap.bin

And then

% jhat -J-mx512m heap.bin

This started a web server, so I did:


Wow! From that page, I was able to browse the heap and find which object has been created by whom. The histo is a very good starting point:


I was looking at all the current active HTTP requests, so I did:

select s from com.sun.enterprise.web.connector.grizzly.ReadTask s where s.byteBuffer.position > 0