I'm looking for a way to count all live objects in heap, grouped by type. Seeing the size of the objects would be a bonus.
Use case: See why my application needs 36 GB of heap while the size of the data it's holding should be only 5 GB.
I haven't been able to figure out how to do it with pprof
. Looks like it only counts allocations, not objects in heap.
In VisualVM (for JVM), a memory snapshot shows this information straight away: