Can someone tell me what does bold, blue one and red one positions in HPROF Viewer in Android Studio means exactly ?
有人能告诉我Android Studio中HPROF Viewer中的粗体,蓝色和红色位置是什么意思?
I ask about one in Reference Tree panel.
我在Reference Tree面板中询问一个。
Best regards.
最好的祝福。
2 个解决方案
#1
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. - bold - GC根,例如深度为0且不应收集的实例。这个答案提供了有关GC根目录的更多信息,这个答案列出了根源的类型。
-
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.
同样,这里的免责声明可能都是错误的,我实际上找不到任何关于此的官方信息,但它确实与我在使用堆分析器时的观察结果相符。
#2
3
-
this$0
(the red one) - is the variable which holds the reference toLeakActivity
. 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.这个$ 0(红色的) - 是保存LeakActivity引用的变量。在您的情况下,这是对封闭类的隐式引用。这是Java中匿名内部类的本质 - 它们隐式地保存对外部(封闭)类的引用。
-
blue class name - is just a location of
this$0
variable.蓝色类名 - 只是这个$ 0变量的一个位置。
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
基本上你所看到的是LeakAsctivity是从LeakAsyncTask中隐式引用的,LeakAsyncTask是作为LeakActivity中的匿名内部类实现的,所以在LeakAsyncTask完成之前,LeakActivity不能被垃圾收集。所以你有一个潜在的Activity泄漏,这对你的应用来说真的很危险
#1
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. - bold - GC根,例如深度为0且不应收集的实例。这个答案提供了有关GC根目录的更多信息,这个答案列出了根源的类型。
-
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.
同样,这里的免责声明可能都是错误的,我实际上找不到任何关于此的官方信息,但它确实与我在使用堆分析器时的观察结果相符。
#2
3
-
this$0
(the red one) - is the variable which holds the reference toLeakActivity
. 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.这个$ 0(红色的) - 是保存LeakActivity引用的变量。在您的情况下,这是对封闭类的隐式引用。这是Java中匿名内部类的本质 - 它们隐式地保存对外部(封闭)类的引用。
-
blue class name - is just a location of
this$0
variable.蓝色类名 - 只是这个$ 0变量的一个位置。
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
基本上你所看到的是LeakAsctivity是从LeakAsyncTask中隐式引用的,LeakAsyncTask是作为LeakActivity中的匿名内部类实现的,所以在LeakAsyncTask完成之前,LeakActivity不能被垃圾收集。所以你有一个潜在的Activity泄漏,这对你的应用来说真的很危险