版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
MAT
在使用MAT分析对象的时候有两个重要的概念
outgoing references ,这个对象引用了哪些对象
incoming references ,哪些对象引用了这个对象
图解
代码
public class A {
private C c1 = C.getInstance();
}
public class B {
private C c2 = C.getInstance();
}
publicclass C {
private static C myC = newC();
public static C getInstance() {
returnmyC;
}
private D d1 = new D();
private E e1 = new E();
}
public class D {
}
public class E {
}
public class SimpleExample {
public static void main (String argsp[]) throws Exception {
A a = new A();
B b = new B();
}
}
示例图
执行命令
jmap -dump:live,format=b,file=3144.bin 3144
分析
在直方图这里输入全限定类名
选择 incoming得到
选择 outgoing