Memory Analyzer tool(MAT)分析内存泄漏---理解Retained Heap、Shallow Heap、GC Root
Shallow Heap Size
指对象自身所占用的内存大小,不包含其引用的对象所占的内存大小。
1、数组类型
数组元素对象所占内存的大小总和。
2、非数组类型
对象与它所有的成员变量大小的总和。当然这里面还会包括一些Java语言特性的数据存储单元。
Retained Heap Size
前对象大小+当前对象可直接或间接引用到的对象的大小总和。
(间接引用的含义:A->B->C, C就是间接引用)
换句话说,Retained Size就是当前对象被GC后,从Heap上总共能释放掉的内存。
不过,释放的时候还要排除被GC Roots直接或间接引用的对象。他们暂时不会被被当做Garbage。GC Roots直接引用了A和B两个对象。
A对象的Retained Size=A对象的Shallow Size
B对象的Retained Size=B对象的Shallow Size + C对象的Shallow Size这里不包括D对象,因为D对象被GC Roots直接引用。
如果GC Roots不引用D对象呢?
GC Roots
The so-called GC (Garbage Collector) roots are objects special for
garbage collector. Garbage collector collects those objects that are not
GC roots and are not accessible by references from GC roots.There are several kinds of GC roots. One object can belong to more than one kind of root. The root kinds are:
- Class - class loaded by system class loader. Such
classes can never be unloaded. They can hold objects via static fields.
Please note that classes loaded by custom class loaders are not roots,
unless corresponding instances ofjava.lang.Class
happen to be roots of other kind(s).- Thread - live thread
- Stack Local - local variable or parameter of Java method
- JNI Local - local variable or parameter of JNI method
- JNI Global - global JNI reference
- Monitor Used - objects used as a monitor for synchronization
- Held by JVM
- objects held from garbage collection by JVM for its purposes.
Actually the list of such objects depends on JVM implementation.
Possible known cases are: the system class loader, a few important
exception classes which the
JVM knows about, a few pre-allocated objects for exception handling,
and custom class loaders when they are in the process of loading
classes.Unfortunately, JVM provides absolutely no additional detail for such objects. Thus it is up to the analyst
to decide to which case a certain "Held by JVM" belongs.If an object is a root, it is specially marked in all views showing
individual objects. For example, the following picture shows a fragment
ofpaths view:
Memory Analyzer tool(MAT)分析内存泄漏---理解Retained Heap、Shallow Heap、GC Root的更多相关文章
- 使用Memory Analyzer tool(MAT)分析内存泄漏(二)
转载自:http://www.blogjava.net/rosen/archive/2010/06/13/323522.html 前言的前言 写blog就是好,在大前提下可以想说什么写什么,不像投稿那 ...
- 使用Memory Analyzer tool(MAT)分析内存泄漏
前言的前言 写blog就是好,在大前提下可以想说什么写什么,不像投稿那么字字斟酌.上周末回了趟成都办事,所以本文来迟了.K117从达州经由达成线往成都方向走的时候,发现铁路边有条河,尽管我现在也不知道 ...
- 使用Memory Analyzer tool(MAT)分析内存泄漏(一)
转载自:http://www.blogjava.net/rosen/archive/2010/05/21/321575.html 前言 在平时工作过程中,有时会遇到OutOfMemoryError,我 ...
- 性能监控 | MAT分析内存泄漏
使用MAT分析内存泄漏(二)八周年重印版 - 知乎 .u-safeAreaInset-top { height: constant(safe-area-inset-top) !important; h ...
- 【转】如何使用MAT分析内存泄漏
原文链接:http://www.lightskystreet.com/2015/09/01/mat_usage/ MAT - Memory Analyzer Tool 使用进阶 Sep 1, 2015 ...
- [原创]Eclipse Memory Analyzer tool(MAT)工个使用介绍
[原创]Eclipse Memory Analyzer tool(MAT)工个使用介绍
- 使用MAT(Memory Analyzer Tool)工具分析dump文件--转
原文地址:http://gao-xianglong.iteye.com/blog/2173140?utm_source=tuicool&utm_medium=referral 前言 生产环境中 ...
- 使用MAT 分析内存泄漏实战
在分析前可以阅读下这篇文章,很多内容就都知道了https://www.jianshu.com/p/738b4f3bc44b,下面我来分析上一篇文章内存泄漏的为问题 1.上一篇中已经生成了hprf的文件 ...
- Android Studio +MAT 分析内存泄漏实战
对于内存泄漏,在Android中如果不注意的话,还是很容易出现的,尤其是在Activity中,比较容易出现,下面我就说下自己是如何查找内存泄露的. 首先什么是内存泄漏? 内存泄漏就是一些已经不使用的对 ...
随机推荐
- Hibernate(十)HQL查询二
一.数据库的emp名和dept表 建立持久化类和配置文件,可以用MyEclipse直接生成 持久化类 package entity; import java.util.Date; public cla ...
- CentOS(学习笔记一)
菜鸟记录 一.配置网络.防火墙等 setup命令 二.查看网络 ifconfig 重启网络 /ect/init.d/network restart 或者ifup ethx(,,)等 查看网络配置文件 ...
- Flume wasn't able to parse timestamp header
来自:http://caiguangguang.blog.51cto.com/1652935/1384187 flume bucketpath的bug一例 测试的配置文件: 1 2 3 4 5 6 7 ...
- U872-结算成本处理步骤及索引处理
U872每月都须要做月结,对于制造企业来说,结算成本处理是不可缺少的一个处理环节,每次查询出来待暂估记录也比較多(我接触到的有3万左右),暂估时间一般要2-3小时左右,若调用的大表索引碎片多时,会须要 ...
- Debian GNU Linux服务列表的获取、服务的关闭/开启、服务在启动时是否自己主动执行的生效/失效
/********************************************************************* * Author : Samson * Date ...
- [Done]BTrace使用小记
项目上线,发现集群机器每隔1小时会准时进行fullgc,JMC中显示了System.gc()触发了fullgc: 代码搜了一下自然是搜不到显示调用这个代码的(谁会这么干!拍死!!!)依赖jar包中到是 ...
- SpringMVC 类内部的RequestMapping注解能否被继承?
首先注意标题,说的是类内部的注解 结论是: 不能,但是子类却可以享有父类中该注解带来的效果. 看了一下这个:http://elf8848.iteye.com/blog/1621392 自己也试了一下, ...
- servlet 多线程
servlet在服务器中只有一个实例,那么它响应请求的方式应该是多线程. 一,servlet容器如何同时处理多个请求. Servlet采用多线程来处理多个请求同时访问,Servelet容器维护了一个线 ...
- log4j 日志 配置 学习
1.用的flume-log4j avrosource的整合 2.学习如何指定类打印日志 #log4j.rootLogger=INFO,flume 这个是将全部的日志会打印出来 log4j.logge ...
- SSO之安装CAS Server
JA-SIG CAS(Central Authentication Service)为Web应用系统提供了单点登录服务.它的特性包括:一个开放和具有很好文档支持的协议:一个Java开源服务器组件:提供 ...