原文:

  http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Fconcepts%2Fheapdump.html

  http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Fconcepts%2Fshallowretainedheap.html

  http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Fconcepts%2Fdominatortree.html

  http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Fconcepts%2Fgcroots.html

  

本文包含:

  1. Heap Dump
  2. Shallow heap  &  Retained
  3. Dominator Tree
  4. Garbage Collection Roots

Heap Dump

  A heap dump is a snapshot of the memory of a Java process at a certain point of time. There are different formats for persisting this data, and depending on the format it may contain different pieces of information, but in general the snapshot contains information about the java objects and classes in the heap at the moment the snapshot was triggered. Usually a full GC is triggered before the heap dump is written so it contains information about the remaining objects.

 heap dump是特定时间点,java进程的内存快照。它有多种格式存储内存数据,通用的快照被触发时java对象和类在heap中的情况。通常一个gc动作在生成heap dump之前,所以它包含的剩余的没有被gc的对象。一般内存快照生成.hprof 等文件。

  The Memory Analyzer is able to work with HPROF binary heap dumps, IBM system dumps (after preprocessing them), and IBM portable heap dumps (PHD) from a variety of platforms.

 Memory Analyzer 是一个可以打开很多格式heap dump文件的工具。

  Typical information which can be found in heap dumps (once more - depending on the heap dump type) is:

 典型的heap dump有下面几个信息:
  • All Objects

      Class, fields, primitive values and references

    类,属性,原始值,引用。
  • All Classes

      Classloader, name, super class, static fields

    类加载器,名字,父类,静态属性。
  • Garbage Collection Roots

      Objects defined to be reachable by the JVM

    jvm使用的对象
  • Thread Stacks and Local Variables

      The call-stacks of threads at the moment of the snapshot, and per-frame information about local objects

    线程栈,本地对象。

  A heap dump does not contain allocation information so it cannot resolve questions like who had created the objects and where they have been created.

  heap dump中不含分配信息,所以不提示对象在哪里分配,被谁分配。

Shallow heap  &  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.

 Shallow heap是对象占用内存的大小。一个引用占 32/64 bits,一个inter占4bytes,一个long占8 bytes等。

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

 Retained set 是引用的外部对象的集合,它应该被gc回收。

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.

 Retained heap 大小是retained set内应被回收的对象的shallow size总和。

  Generally speaking, shallow heap of an object is its size in the heap and retained size of the same object is the amount of heap memory that will be freed when the object is garbage collected.

 对象的shallow heap是它在堆上占用的大小。
 对象的retained size 是将要释放的堆大小。

  The retained set for a leading set of objects, such as all objects of a particular class or all objects of all classes loaded by a particular class loader or simply a bunch of arbitrary objects, is the set of objects that is released if all objects of that leading set become unaccessible. The retained set includes these objects as well as all other objects only accessible through these objects. The retained size is the total heap size of all objects contained in the retained set.

 Leading set 是retained set子集,它内存存放一些重要的关键点对象,比如一些特殊的类,或特殊加载类加载的类,或一些有专门工作的对象。retained size就是retained set内所有对象大小之和。
 关于Leading set与 Retained Set 请参看下面例子:

Figure 1. GC Roots,Leading Set,Retained Set

  The Minimum Retained Size gives a good (under) estimation of the retained size which is calculated ways faster than the exact retained size of a set of objects. It only depends on the number of objects in the inspected set, not the number of objects in the heap dump.

Dominator Tree

  Memory Analyzer provides a dominator tree of the object graph. The transformation of the object reference graph into a dominator tree allows you to easily identify the biggest chunks of retained memory and the keep-alive dependencies among objects. Bellow is an informal definition of the terms.

 Memory Analyzer工具提供了对象控制者树,它由描述,它可以让你轻松的标识出引用的最大内存块,和其中仍然活跃的对象。
 下面是它们之间关系的非正式定义:

  An object x dominates an object y if every path in the object graph from the start (or the root) node to y must go through x.

 x控制y的定义:从图中开始顶点到顶点 y ,必经过x,那么x控制y。

  The immediate dominator x of some object y is the dominator closest to the object y.

 y的最近控制者:离y最近的控制y的顶点。

  A dominator tree is built out of the object graph. In the dominator tree each object is the immediate dominator of its children, so dependencies between the objects are easily identified.

 Dominator tree 是根据控制对象关系的图生成的一棵树,其中每个节点都是它子树的控制者。
 它主要有下面几个特点:

  The dominator tree has the following important properties:

  • The objects belonging to the sub-tree of x (i.e. the objects dominated by x ) represent the retained set of x .

    每个节点的大小包含其子树节点大小。
  • If x is the immediate dominator of y , then the immediate dominator of x also dominates y , and so on.
    控制有传递性。
  • The edges in the dominator tree do not directly correspond to object references from the object graph.
    根节点不对应图中的顶点。如下:

        

            Figure 2. dominator tree
 

Garbage Collection Roots

  Garbage Collections Roots (GC roots) are objects that are kept alive by the Virtual Machines itself. These include for example the thread objects of the threads currently running, objects currently on the call stack and classes loaded by the system class loader.

  The (reverse) reference chain from an object to a GC root - the so called path to GC roots - explains why the object cannot be garbage collected. The path helps solving the classical memory leak in Java: those leaks exist because an object is still referenced even though the program logic will not access the object anymore.

 GC Roots 是JVM 管理的对象集而非java进程堆中的对象。
 这和Figure1 描述的有点不同:
 还有些讨论: http://stackoverflow.com/questions/6366211/what-are-the-roots

  The Garbage Collector (GC)  is responsible for removing objects that will never be accessed anymore. Objects cannot be accessed if they are not reachable through any reference chain. The starting point of this analysis are the Garbage Collection Roots, i.e. objects that are assumed to be reachable by the virtual machine itself. Objects that are reachable from the GC roots remain in memory, objects that are not reachable are garbage collected.

  Common GC Roots are objects on the call stack of the current thread (e.g. method parameters and local variables), the thread itself, classes loaded by the system class loader and objects kept alive due to native code.

  GC Roots are very important when determining why an object is still kept in memory: The reference chain from an arbitrary object to the GC roots (Path to GC Roots...) tells who is accidentally keeping a reference.

  A garbage collection root is an object that is accessible from outside the heap. The following reasons make an object a GC root:

 一个 GC root 是一个内存堆外部的对象,一般产生它的原因如下:
System Class Class loaded by bootstrap/system class loader. For example, everything from the rt.jar like java.util.* .

由系统类加载。比如 rt.jar内java.util.*;包下的类。
JNI Local Local variable in native code, such as user defined JNI code or JVM internal code.

有本地局部变量的引用,比如在本地jni代码或jvm中。
JNI Global Global variable in native code, such as user defined JNI code or JVM internal code.

有本地全局变量的引用,
Thread Block Object referred to from a currently active thread block.

被阻塞的线程引用。
Thread A started, but not stopped, thread.

有没有停止的线程。
Busy Monitor

Everything that has called wait() or notify() or that is synchronized. For example, by calling synchronized

(Object) or by entering a synchronized method. Static method means class, non-static method means object.

同步等待中。静态方法意味着类,非静态方法意味着对象。
Java Local

Local variable. For example, input parameters or locally created objects of methods that are

still in the stack of a thread.

本地变量仍然在栈呀线程中。
Native Stack

In or out parameters in native code, such as user defined JNI code or JVM internal code. This is often the

case as many methods have native parts and the objects handled as method parameters become GC roots.

For example, parameters used for file/network I/O methods or reflection.

本地代码的参数或返回值。
Finalizable An object which is in a queue awaiting its finalizer to be run.

对象处在定稿队列。
Unfinalized An object which has a finalize method, but has not been finalized and is not yet on the finalizer queue.

一个对象拥有还没有定稿的方法,且还没有加入到定稿队列。
Unreachable

An object which is unreachable from any other root, but has been marked as a root by MAT to retain

objects which otherwise would not be included in the analysis.

一个在mat分析器搜索范围之外的对象。
Java Stack Frame

A Java stack frame, holding local variables. Only generated when the dump is parsed with the preference

set to treat Java stack frames as objects.

把Java Stack frames 当作了一个对象。
Unknown

An object of unknown root type. Some dumps, such as IBM Portable Heap Dump files, do not have root

information. For these dumps the MAT parser marks objects which are have no inbound references or

are unreachable from any other root as roots of this type. This ensures that MAT retains all the objects

in the dump.

不识别的类型。
  
  
  

 

Android内存管理(9)*MAT:Heap Dump,Shallow Heap,Retained Heap,Dominating Tree,GC Roots等的含义的更多相关文章

  1. Android内存管理(10)MAT: 基本教程

    原文: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Fgettingstarted%2Fbasic ...

  2. [Android Memory] Android内存管理、监测剖析

    转载自:http://blog.csdn.net/anlegor/article/details/23398785 Android内存管理机制: Android内存管理主要有:LowMemory Ki ...

  3. Android 内存管理分析(四)

    尊重原创作者,转载请注明出处: http://blog.csdn.net/gemmem/article/details/8920039 最近在网上看了不少Android内存管理方面的博文,但是文章大多 ...

  4. 浅谈Android内存管理

    最近在网上看了不少Android内存管理方面的博文,但是文章大多都是就单个方面去介绍内存管理,没有能全局把握,缺乏系统性阐述,而且有些观点有误,仅仅知道这些,还是无法从整体上理解内存管理,对培养系统优 ...

  5. Android——内存管理基础

    内存收集概念 内存垃圾收集器(garbage collector) 概念:自定内存管理. 功能:分配内存.保证所有被引用的对象还在内存中.可以释放在运行的代码中不再引用的对象的内存. 垃圾收集器避免了 ...

  6. Android内存管理机制之一:low memory killer

    转载自http://www.miui.com/thread-29268-1-1.html 准备写这个专题之前,心里是有点忐忑的.首先Android内存管理机制相当复杂,想要讲清楚比较困难:其次对于绝大 ...

  7. 移动端测试===Android内存管理: 理解App的PSS

    Android内存管理: 理解App的PSS 原文链接:http://www.littleeye.co/blog/2013/06/11/android-memory-management-unders ...

  8. Android 内存管理中的 Shallow heap Retained heap

    所有包含Heap Profling功能的工具(MAT,Yourkit,JProfiler,TPTP等)都会使用到两个名词,一个是Shallow heap Size,另一个是 Retained heap ...

  9. Android 内存管理 &Memory Leak & OOM 分析

    转载博客:http://blog.csdn.net/vshuang/article/details/39647167 1.Android 进程管理&内存 Android主要应用在嵌入式设备当中 ...

随机推荐

  1. 微信小程序-template模板

    ============================= 构建template模板                    ============================= 1.分析得出共为 ...

  2. [转] angular2+highcharts+chart.js

    这里是在ionic2下使用highchairs和chart.js的简单示例chartjs部分参考http://www.jianshu.com/p/bc18132da812 1.安装hightchart ...

  3. [bzoj2657][Zjoi2012]旅游 journey_ 对偶图_树形dp

    旅游 bzoj-2657 Zjoi-2012 题目大意:题目链接 注释:$1\le K\le 2\cdot 10^5$. 想法:这题... 感觉和上一个题的提示有些类似,就是题目生怕你不知道这是一道对 ...

  4. cogs——1786. 韩信点兵

    1786. 韩信点兵 ★★★   输入文件:HanXin.in   输出文件:HanXin.out   简单对比 时间限制:1 s   内存限制:256 MB [题目描述] 韩信是中国军事思想“谋战” ...

  5. 使用 IAsyncResult 调用异步方法

    .NET Framework 和第三方类库中的类型可以提供允许应用程序在主应用程序线程之外的线程中执行异步操作的同时继续执行的方法.下面几部分介绍了在调用使用 IAsyncResult 设计模式的异步 ...

  6. spring mvc参数校验

    一.在SringMVC中使用 使用注解 1.准备校验时使用的JAR validation-api-1.0.0.GA.jar:JDK的接口: hibernate-validator-4.2.0.Fina ...

  7. org.apache.shiro.web.servlet.ShiroHttpServletRequest cannot be cast to org.springframwork.web.mult..

    在用dwz框架+spring MVC时上传文件报的错 详细错误例如以下: 事实上就是一个类型转换错误,但却研究了好长时间,怎么都不知道哪里错了.由于前面卸过一个文件上传的和这个差点儿相同,那个就没有问 ...

  8. 自由宣言--《I Have a Dream》(马丁.路德.金)

    I Have a Dream by Martin Luther King, Jr. I am happy to join with you today in what will go down in ...

  9. layoutSubviews, setNeedsLayout, layoutIfNeeded

    layoutSubviews总结 ios layout机制相关方法 - (CGSize)sizeThatFits:(CGSize)size- (void)sizeToFit——————- - (voi ...

  10. 5分钟Serverless实践 | 构建无服务器的敏感词过滤后端系统

    前言 在上一篇“5分钟Serverless实践”系列文章中,我们介绍了什么是Serverless,以及如何构建一个无服务器的图片鉴黄Web应用,本文将延续这个话题,以敏感词过滤为例,介绍如何构建一个无 ...