What do the Android Studio HPROF reference tree element colours represent?
Asked Answered
P

2

18

Can someone tell me what does bold, blue one and red one positions in HPROF Viewer in Android Studio means exactly ?

I ask about one in Reference Tree panel.

Bold item

Blue item

Red item

Best regards.

Polemoniaceous answered 27/2, 2016 at 20:18 Comment(2)
You may wish to upload a screenshot somewhere, showing what you are referring to, and linking to that screenshot from your question. It will be difficult for this question to help others in the future without it, and it may also help you get answers to your question.Fart
@Fart I've added screenshots.Polemoniaceous
C
13

I can't find any documentation on this, but from looking through a few heap dumps this is what they seem to be:

  • blue - The closest dominator of the instance selected in the top-right pane.
  • bold - A GC root, eg an instance with depth 0 that should not be collected. This answer has more information on what a GC root is, and this answer lists the types of things that are roots.
  • red - I haven't actually seen these, but I would guess it indicates an instance that should be garbage collected, but hasn't been yet.

Again, a disclaimer here is that this could all be wrong and I can't actually find any official information about this, but it does seem to match up with my observations when using the heap profiler.

Casiano answered 10/5, 2016 at 0:21 Comment(0)
L
3
  • this$0 (the red one) - is the variable which holds the reference to LeakActivity. In your case this is an implicit reference to the enclosing class. This is a nature of anonymous inner classes in Java - they implicitly hold a reference to the outer (enclosing) class.

  • blue class name - is just a location of this$0 variable.

So essentially what you are seeing - is LeakActivity is implicitly referenced from LeakAsyncTask which is implemented as anonymous inner class within LeakActivity, so LeakActivity cannot be garbage collected until LeakAsyncTask is finished. So you have a potential Activity leak which is really dangerous for your app

Lisk answered 27/2, 2016 at 20:35 Comment(2)
I mean red one like on last screenshot. I thought that red one is objects that are not references anymore but there are still in memory (will be GCed soon). But I wanted to be sure and also I wanted to know what means bold and blue ones. Because some of the item (this is how are you explained blue items) are pointing location either and are black so I don't think blue color means location of reference.Polemoniaceous
ah, I see.. Not sure, honestly what do they mean. Need to play a bit with samples.. Will come back here once I have more info :)Lisk

© 2022 - 2024 — McMap. All rights reserved.