YourKit Java Profiler is capable of measuring shallow and retained sizes of objects.
Shallow size of an object is the amount of memory allocated to store the object itself, not taking into account the referenced objects. Shallow size of a regular (non-array) object depends on the number and types of its fields. Shallow size of an array depends on the array length and the type of its elements (objects, primitive types). Shallow size of a set of objects represents the sum of shallow sizes of all objects in the set.
Retained size of an object is its shallow size plus the shallow sizes of the objects that are accessible, directly or indirectly, only from this object. In other words, the retained size represents the amount of memory that will be freed by the garbage collector when this object is collected.
To better understand the notion of the retained size, let us look at the following examples:
In order to measure the retained sizes, all objects in memory are treated as nodes of a graph where its edges represent references from objects to objects. There are also special nodes - GC root objects, which will not be collected by Garbage Collector at the time of measuring (read more about GC roots).
The pictures below show the same set of objects, but with varying internal references.
Figure 1:
|
Figure 2:
|
|
|
Let us consider obj1.
As you can see, in both pictures we have highlighted all of the objects that are directly or indirectly accessed only by obj1. If you look at Figure 1, you will see that obj3 is not highlighted, because it is also referenced by a GC root object. On Figure 2, however, it is already included into the retained set, unlike obj5, which is still referenced by GC root.
Thus, the retained size of obj1 will represent the following respective values:
- For Figure 1: the sum of shallow sizes of obj1, obj2 and obj4
- For Figure 2: the sum of shallow sizes of obj1, obj2, obj3 and obj4
Looking at obj2, however, we see that its retained size in the above cases will be:
- For Figure 1: the sum of shallow sizes of obj2 and obj4
- For Figure 2: the sum of shallow sizes of obj2, obj3 and obj4
In general, retained size is an integral measure, which helps to understand the structure (clustering) of memory and the dependencies between object subgraphs, as well as find potential roots of those subgraphs.
转自:http://www.yourkit.com/docs/90/help/sizes.jsp
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 of
java.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 of paths view:
分享到:
相关推荐
标题中的“Shallow and Deep Networks Intrusion Detection System: A Taxonomy and Survey”指向了文档探讨的核心,即浅层网络和深层网络在入侵检测系统(IDS)中的应用,并提出了一种分类法和调研。这一标题强调了对...
:shallow_pan_of_food: 那顿饭 :green_salad: 关于that.meal是发现新食谱的平台。 只需搜索您想要的食谱,甚至是一种成分,即可从各种可能性中获取灵感。 :laptop: 运行这个程序#clone this repo$ git clone ...
赛义德带来完美无接触的就餐体验···目录用法路线图贡献接触 关于该项目 该项目旨在带来完美的非接触式用餐体验,来餐厅的顾客可以扫描二维码并在各自的屏幕上获取菜单。 这就是我们提供给客户的东西客户可以扫描...
love_in :dog_face: This is a miniprogram which to display the photos from tuchong. love_in :artist_palette: 情林 微信小程序 一个艺术摄影作品的图片分享社区 功能开发中……
在这个项目中,我们提出了一种浅层神经网络架构Shallow-UWnet,该架构与最新的水下图像增强模型相比,可保持性能且参数较少。 我们通过在综合和真实数据集的组合中对模型的性能进行基准测试,证明了模型的一般性。 ...
Chapter 8 Surveying: Shallow Opinions, Identities, and Reports of Acts Chapter 9 Interviewing: Deep Talk to Gather Several Types of Data Chapter 10 Scales: Looking for Underlying Traits Chapter 11 ...
A Shallow Introduction to Perl and Python
mathematicians and those who “hated math in school.” The book is organized into two sections: (I) Beauty for the Eye (shallow water for the non-swimmer); and (II) A Feast for the Mind (slowly ...
用法 $ shallow-water --helpshallow_water 0.1.0USAGE: shallow-water --parameters <PARAMETERS> [SUBCOMMAND]FLAGS: -h, --help Prints help information -V, --version Prints version information
"shallow-equals" 是一个专门用于浅层比较的开源库,它为开发者提供了便捷的方式来判断两个数据结构是否在表面级别(即只检查第一层属性)上相同。这个库尤其适用于那些性能敏感的场景,例如在React组件的...
标题中的"Lattice-Boltzmann-Methods-for-Shallow-Water-Flows.pdf"指明了文档的主要内容是探讨用晶格玻尔兹曼方法(Lattice Boltzmann Method,简称LBM)来求解浅水流动方程。这个标题揭示了文档的研究领域和使用的...
this is a C++ code of shallow water equation
此外,"His arguments seemed shallow and tedious." 提到的“shallow arguments”指的是缺乏深度和说服力的论点。 在搭配上,"shallow"可以与多种名词进行组合,形成如"shallow argument"(浅薄的论据)、"shallow...
标题“SHALLOW”可能指的是一个特定的字体设计或者与字体设计相关的项目。在这个场景下,我们来深入探讨一下“字体”这一主题。 字体是视觉传达中的一个重要元素,它影响着信息的阅读性和感知效果。在计算机领域,...
### 一维浅水模型(1D Shallow Water Model):溃坝问题的数值求解 一维浅水模型是流体力学中的一个重要工具,用于模拟河流、湖泊、海洋等自由表面流体的运动,特别是在洪水模拟、海岸工程、环境评估等领域有着广泛...
在“shallow_water_2d.m”这个MATLAB文件中,我们可以预期看到以下内容: 1. **初始化**:定义网格大小、时间步长、模拟时间范围以及初始条件。这些参数对数值解的质量至关重要,网格越细密,结果越精确;时间步长...
"Spatial-Phase Shallow Learning Rethinking Face Forgery Detection in Frequency Domain" 这篇论文聚焦于利用频域信息,特别是相位谱,来提升人脸识别伪造检测的性能。研究指出,大多数的人脸伪造技术都会涉及到...
- **Retained Heap**:是指 Retained Set 中所有对象的 Shallow Heap 之和,即因对象 X 而保持活跃的内存总量。 一组领先对象(Leading Objects)的 Retained Set 在这些对象变得不可达时将会被释放。领先对象集的...
Shallow Heap表示对象本身占用的内存总量,而Retained Heap则表示由于某个对象而保持活跃状态的内存大小,即对象的Retained Set中所有对象的Shallow Heap之和。Retained Set是指一旦对象被垃圾回收,那些也会被回收...