首页  

内存分析工具MAT中的重要概念     所属分类 MAT 浏览量 193
Memory Analyzer  Concepts


Heap Dump
Reachability
Shallow vs. Retained Heap
Dominator Tree
Garbage Collection Roots



A heap dump is a snapshot of the memory of a Java process at a certain point of time.

堆快照
对象 类 GC根集 线程栈 和 本地局部变量 

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

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

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


Reachability 可达性

Objects in a heap dump have references to other objects. 
These can either be via field references (for simple objects), array elements (for object arrays) or via various hidden references. 
For instance every object contains a reference to its type, and each class contain a reference to the class loader which loaded the class.

引用  字段 数组元素   对象指向类  类包含类加载器的引用

These objects and references form a directed graph. 
The objects are the nodes, the references are the directed links between the nodes. 
The garbage collection roots are the roots of this graph.

对象 + 引用   有向图


Reachable Unreachable
If there is no path from a garbage collection root to an object then it is unreachable. 
没有被GC根对象直接或间接引用的对像不可达 , 可以被安全的回收


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.

shallow heap of an object is its size in the heap 
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 Heap  该对象被回收之后,会释放的内存大小


Dominator Tree

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.
The immediate dominator x of some object y is the dominator closest to the object y.

引用树  控制树

控制  直接控制

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.

x的控制树 就是 retained set of x
控制传递性
控制树中的边并不直接对应于对象图中的对象引用

 Garbage Collection Roots 

上一篇     下一篇
netty ChannelFuture 实例

netty异常处理机制

Garbage Collection Roots

获取jvm heap dump 的几种方式

MAT内存泄露分析实战

MAT内存分析之OQL