[英]VisualVM - Find all references to a class
I am attempting to debug a permgen error in an application. 我试图在应用程序中调试permgen错误。 I am running VisualVM to profile the app and have taken a heapdump of the memory snapshot. 我正在运行VisualVM来分析应用程序,并采取了内存快照的堆转换。
Loading the snapshot into VisualVM for analysis, I can currently see in the classes list several classes appearing several times, all listed with 0 instances, 0 size - I am only expecting one of these classes each (probably linked to its classloader) - Is there any way to determine what is still holding references to these classes with no instances? 将快照加载到VisualVM中进行分析,我现在可以在类列表中看到几个出现多次的类,都列出了0个实例,0个大小 - 我只期望每个类中的一个(可能链接到它的类加载器) - 是否存在有什么方法可以确定什么仍然保持对没有实例的这些类的引用? Happy to use another tool if I can just load in the dump(.hprof) to analyze what is holding the reference. 很高兴使用另一个工具,如果我可以加载转储(.hprof)来分析持有引用的内容。
Thanks! 谢谢!
Well, saying "use MAT" doesn't really answer the question! 好吧,说“使用MAT”并没有真正回答这个问题!
To do it in VisualVM, in the Sampler or Profiler view there is a button (top right) labeled "Heap Dump". 要在VisualVM中,在Sampler或Profiler视图中,有一个标记为“Heap Dump”的按钮(右上角)。 Click this, which opens the heap analyser. 单击此按钮,打开堆分析器。 Under the "Classes" tab, all loaded classes are shown. 在“类”选项卡下,显示所有已加载的类。 At the bottom there is a search box, type the class name you are interested in, in the filtered view double click the class in question. 在底部有一个搜索框,键入您感兴趣的类名,在过滤后的视图中双击相关的类。
This opens the instances view. 这将打开实例视图。 Right-click an instance int the left pane, and select "Show Nearest GC Root" to find what is referencing the object. 右键单击左窗格中的实例,然后选择“显示最近的GC根”以查找引用该对象的内容。
Barney 巴尼
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.