views:

55

answers:

2

Is there a tool which could be used to analyse the objects being created between two separate garbage collection run (= number of objects created and their type) ?

Heapdumps dont really work here as they perform a GC when they're invoked (or at least that's what I observed everytime so far), and I want to see which objects are collected by the GC, not which objects are left after the GC run, if that makes sense.

+1  A: 

First, when you always observe a full garbage collection before each heap dump, you probably called it like this:

jmap -histo:live $PID

If that's the case, just leave out the :live, which will suppress the explicit garbage collection.

In addition, the Sun JVM knows the following command line options:

-XX:+PrintClassHistogramBeforeFullGC -XX:+PrintClassHistogramAfterFullGC

That should be pretty much what you want.

Roland Illig
A: 

If you need to know which objects are collected by GC, the 'Unreachable objects histogram' from Eclipse Memory Analyzer may help.

antispam