incoming references aggregated view

Questions about YourKit Java Profiler
Post Reply
grandinj
Posts: 4
Joined: Thu Apr 21, 2005 7:35 am

incoming references aggregated view

Post by grandinj »

Hi

I have tons of small objects which are referenced from various places.

What I want is a summarized view of incoming references.
ie. I want to know that object A is referenced by 50 copies of B and also by 1000 copies of object C.

A suggested display would look something like the "incoming references" view but with an additional column for "number of objects".

That would let me explore back along the reference path to see where the culprits are, without having to open tons of objects and make guesses.

Thanks.
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

Actually incoming/outcoming reference views are weak instrument to explore heap. If you are finding memory leak (why particular obect is not collected), try to find path to GC root.
grandinj
Posts: 4
Joined: Thu Apr 21, 2005 7:35 am

Post by grandinj »

It's not a leak.

I'm profiling certain usages of Eclipse, and it generates enormous numbers of
small objects.

I need to know what percentages of objects linked to a central object are of each type, so I know where to focus my efforts.

This is not an isolated problem - I often run across this when attempting to optimize systems that have fine grained internal data models and/or large caches.

Normally I investigate 10-50 of the object references by hand to get a "feel" for which objects are causing the problem, but that gets very tiring, especially when it seems like something the computer could do for me quite easily.
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

OK. How will you use information that A is referenced by 50 copies of B and also by 1000 copies of object C? I'm asking because it's not clear to me how this information could be used for _optimization_.
grandinj
Posts: 4
Joined: Thu Apr 21, 2005 7:35 am

Post by grandinj »

For example, I have an object A, which I can see in the "class list" view is occupying a lot of memory.

I switch to the "Instances of A" view, and select "Incoming References".
But because this object is held in a deeply nested structure I see lots of
"Group of 500 objects" in my list.

So I try using "find path from GC roots" and set the number very high, but then I get tons of results.

What I want is an aggregated "find path from GC roots" view, so that I know for sure where the bulk of the references are coming from.

I don't want to have to sample half a dozen individual objects and discover later on that the object is being referenced in more than one way and I chose the wrong ones to look at.

It is more a matter of "this object is referenced by 1000 copies of B and 50 copies of C. If I happen to get unlucky and look at the C references first, then I will be wasting time and optimizing the wrong thing".

But if I know the numbers for sure, I can proceed with confidence and pick B as my starting point for improving memory usage.

This gets particularly useful when trying to find where common objects like String/Integer/etc/char[]/byte[] are being held from.
grandinj
Posts: 4
Joined: Thu Apr 21, 2005 7:35 am

Post by grandinj »

Maybe it would help if I said that this is not about finding a bug in the memory allocation, or finding a reference that should not be held.

The allocations are good, they are just potentially wasteful.

This is about getting an overall picture of the objects allocated so that I can reduce the number of objects (where possible) and reduce the size of the data structures holding information (where I can't drop the objects themselves) or reducing the caching (where the cost of recreating the objects is less than the cost of the memory).
chadm
Posts: 4
Joined: Wed Apr 27, 2005 6:31 pm

Post by chadm »

It would be very valuable to view references agregated by class rather than individually by instance.

For example. If I see 10 instances of A and view incoming references to it I may see 10, 5, 20 instances of B. It would be handy if YourKit rendered it like this.


[5]B->[10]A

Indicating that there are 5 instances of B that collectively refer to 10 instances of A. A more complex example where this becomes very useful is:


[1]B->[100]A
[10]C->[10]A

I know immediatly that I can focus my attention on class B
Post Reply