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 Elike Hodo
: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 ...
SHALLOW
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
this is a C++ code of shallow water equation
driven machine learning with human knowledge (common priors or implicit intuitions) can effectively lead to explainable, robust, and general AI, as follows: from shallow computation to deep neural ...
DeepCopy-ShallowCopy:DeepCopy&ShallowCopy
Spatial-Phase Shallow Learning Rethinking Face Forgery Detection in Frequency Domain
SHALLOW LEARNING FOR DEEP NETWORKS文章全文,本文介绍了另一种深度网络的训练方法——SHALLOW LEARNING
前端开源库-shallow-equalsShallow等于,确定一个数组或对象是否与另一个数组或对象等效,
In order to work efficiently with high adjacency effects and water bottom reflectance in shallow inland lakes, the image statistics method is suggested for the SACA algorithm to determine the aerosol...
Big Data in Omics and Imaging: Association Analysis addresses the recent development of association analysis and machine learning for both population and family genomic data in sequencing era....
求解一维浅水方程源代码,C++代码,算例为一维溃坝问题。
Retained Heap :是shallow Heap的总和(单个对象占用内存*此对象的个数),也就是该对象被GC之后所能回收到内存的总和 分析方式: 1.查找线程下占用内存较大的对象(上图右边) 2.定位对象在代码里出现的位置...