如何使用堆转储识别 Java Memory Analyzer 中对象的引用持有者 [英] How to identify holder of reference to object in Java Memory Analyzer using heap dump

查看:36
本文介绍了如何使用堆转储识别 Java Memory Analyzer 中对象的引用持有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我在某个应用程序中遇到 OutOfMemoryErrors 问题,所以我想找出根本原因.我从 AIX 服务器上的 IBM VM 创建了一个堆转储 (PHD),并尝试使用 IBM Support Assistant 4.1 及其内存分析器工具对其进行分析.

As i have some problems with OutOfMemoryErrors with an application i want to identify the root cause. This i created a heap dump (PHD) from the IBM VM on the AIX server and tried to analyze it using IBM Support assistant 4.1 and its Memory Analyzer tool.

解析堆转储时,ISA 询问我是否要运行泄漏嫌疑报告.

When the heap dump is parsed ISA asks me if i want to run the leak suspect report.

使用泄漏方面的支持,我获得了一些消耗大量内存的类的信息.

Using the leak respect support i got the information about some classes which consume considerable amount of memory.

我现在想确定的是对象引用的持有者,但我可以例如只查看 ArrayList 包含哪些对象,而不查看谁持有对该 ArrayList 的引用.

What i now want to identify is the holder of the object references, but i can e.g. only see what objects a ArrayList contains, but not who holds a reference to that ArrayList.

我如何获得这些信息?

推荐答案

在内存分析器 (MAT) 中加载堆转储.

Load you heap Dump in Memory Analyzer (MAT).

转到直方图并查看大尺寸对象.

Go to Histogram and see the big size Object.

现在右键单击它并选择立即支配者.它将打开一棵支配树,您可以识别持有您的对象的内容.

Now right click on this and select Immediate dominators. It will open a dominator tree and u can identify what is holding your object.

有时当大尺寸对象是局部变量时,您将无法在树中看到直接支配者.它只能告诉你你的变量是哪个线程的一部分.(下图没有显示这个局部变量场景)

Sometimes when the big size object is local variable you will not be able to see immediate dominators in tree. It can only tell you that your variable is part of which thread.(Below image doesn't show this local variable scenario)

在那种情况下检查(堆栈跟踪)你在哪里得到 OutOfMemoryError.然后相应地向后追溯并尝试找出您在哪种方法中将大尺寸对象创建为局部变量.大多数情况下,我们以相同的方法获得大尺寸对象,这在堆栈跟踪中显示,因为在分配更多内存时,我们会得到 OutOfMemoryError.

In that case check (stack trace ) where are you getting OutOfMemoryError. Then accordingly trace it backwards and try to find out in which method are you creating big size objects as local variables. Most of the cases we get big size objects in same method which is shown in stack trace as at some point of time while allocating more memory we get OutOfMemoryError.

更多详情.

这篇关于如何使用堆转储识别 Java Memory Analyzer 中对象的引用持有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆