MAT outgoing references / incoming references

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_22222499/article/details/100069126

文章目录

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
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_22222499/article/details/100069126