Memory Analysis内存分析工具复习

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

最近因为系统问题,所以又对Memory Analysis工具进行复习(for eclipse的)

通过dump出来的文件,然后在eclipse上用Memory Analysis工具(可以在线安装很简单)

内存泄漏查找思路一:

打开Leak Suspects->Problem Suspect N下的“Details”

打开此页面后,有几个内容:

1、引用累计关系(shortest paths to the accumulation point)

2、存储对象(accumulated objects)

3、存储对象所属类名(accumulated objects by Class)

 

这种方式很简单并且很直观,知道那些对象了去查找类和引用点。

 

内存泄漏查找思路二:

1、打开直方图(Histogram),过滤找到自己的类,然后在此记录上右键“list objects”下选择“with incoming references”

得到是那些对象引用了此类。

2、再从这些对象记录选择一条右键“Path to GC Roots”->"exclude weak references",得到层次引用关系,就知道了point。

如果对代码很熟悉,能猜出是那个类会引起泄漏,就可以用这种方式

 

 

备注:

Shallow vs. Retained Heap

Shallow heap is the memory consumed by one object. An object needs 32 or 64 bits (depending on the OS architecture) per reference, 4 bytes per Integer, 8 bytes per Long, etc. Depending on the heap dump format the size may be adjusted (e.g. aligned to 8, etc...) to model better the real consumption of the VM.

Retained set of X is the set of objects which would be removed by GC when X is garbage collected.

Retained heap of X is the sum of shallow sizes of all objects in the retained set of X, i.e. memory kept alive by X.

 

关于相关更详细的资料可以参考帮助和网上资料。

展开阅读全文

没有更多推荐了,返回首页