我正在使用 Memory Analyzer分析我的程序内存消耗。我有一些大对象,我想在满足某些条件后让它们符合 GC 的条件,实际上,当这些条件发生时,我希望在控制台上看到一行,表明自从我添加了一条日志行以来,这些对象中的任何一个都已完成在重写对象的 finalize 方法中。所以看起来这些对象从来没有 GC,我想跟踪哪些对象持有对那些阻止其 GC 的特定对象的引用。它是怎么做到的?
最佳答案
引用 the documentation :
When you see something suspicious, right-click on the item and select Path To GC Roots > exclude weak references. This opens a new tab that traces the references to that object which is causing the alleged leak.
您可能还对 Patrick Duboy 关于此主题的 Google I|O 2011 演讲感兴趣。这里是the slides和 the video .
关于android - 如何检查阻止对象符合垃圾收集条件的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22282769/