Take heapdump on GC?

Bernd Eckenfels bernd-2013 at eckenfels.net
Mon Dec 23 14:04:01 PST 2013


Am 23.12.2013, 09:31 Uhr, schrieb Guoqin Zheng <lanson.zheng at gmail.com>:

> I have an application that fills up young gen in seconds. I want to take  
> a
> heap dump on young gen collection, so that I can see what eats up the  
> young
> gen so fast. How can I take such dump just before GC?

Filling up YoungGen in seconds is not that unusual (especially when the YG  
is too small). If you want to catch the app in the act I guess it is the  
best to do it programmatically by waiting a specified time after the last  
YGC happened. The last YGC can be determined from JMX as well as  
triggering the heapdump. I dont think there is a hook which can be called  
before the YGC starts.

Poll the following tabular data entry to see the time od the last YGC:

java.lang:type=GarbageCollector,name=PS Scavenge # LastGcInfo # endTime

Schedule a thread to trigger in x seconds afterwards with:

com.sun.management:type=HotSpotDiagnostic # dumpHeap(filename, false);

On the other hand, it might be easier to simply take a vew heap  
historgrams every second or something.

Greetings
Bernd
-- 
http://bernd.eckenfels.net


More information about the hotspot-gc-use mailing list