Shallow Size Vs Retained Size
- Shallow Size Vs Retained Size Android
- Shallow Vs Retained Size
- Shallow Size Vs Retained Size Conversion
Can't find your answer? Please refer to documentation and demos, ask your question in forum, or contact support.
As experience has shown, sometimes a sort of uncertainty may arise on the subject of Java Virtual Machine (JVM) memory structure and other related aspects such as sizes of various kinds of memory, live and dead objects, etc.
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. The size of the size is defined by the data in the underlying memory space, so it is definitely related to the CPU. For example, if the CPU only supports the small-end mode and the OS is not to store data according to the big end mode (this is certainly crazy), the size of the size will cost a certain resource.
In this article, we shall try to illuminate these issues to clear up the point.
- Particle size grading. Historically a sequential series of screens was used to sort particle sizes. Each of these screens has a differing number of wires and openings per inch. As material passes through one screen and is retained on another we can sort them into size categories. ANSI B74.12 defines the size distribution of particles.
- The Shallow size column displays the sum of shallow sizes of all objects created by a certain constructor function. The Retained size column displays the maximum retained size among the same set of objects. The.Distance.displays the distance to the root using the shortest simple path of nodes.
Heap and Non-Heap Memory
The JVM memory consists of the following segments:
- Heap Memory, which is the storage for Java objects
- Non-Heap Memory, which is used by Java to store loaded classes and other meta-data
- JVM code itself, JVM internal structures, loaded profiler agent code and data, etc.
Heap
The JVM has a heap that is the runtime data area from which memory for all class instances and arrays are allocated. It is created at the JVM start-up.
The heap size may be configured with the following VM options:
- -Xmx<size> - to set the maximum Java heap size
- -Xms<size> - to set the initial Java heap size
By default, the maximum heap size is 64 Mb.
Heap memory for objects is reclaimed by an automatic memory management system which is known as a garbage collector. The heap may be of a fixed size or may be expanded and shrunk, depending on the garbage collector's strategy.
Non-HeapAlso, the JVM has memory other than the heap, referred to as non-heap memory. It is created at the JVM startup and stores per-class structures such as runtime constant pool, field and method data, and the code for methods and constructors, as well as interned Strings.
Unfortunately, the only information JVM provides on non-heap memory is its overall size. No detailed information on non-heap memory content is available.
The abnormal growth of non-heap memory size may indicate a potential problem, in this case you may check up the following:
- If there are class loading issues such as leaked loaders. In this case, the problem may be solved with the help of Class loaders view.
- If there are strings being massively interned. For detection of such problem, Object allocation recording may be used.
If the application indeed needs that much of non-heap memory and the default maximum size of 64 Mb is not enough, you may enlarge the maximum size with the help of -XX:MaxPermSize
VM option. For example, -XX:MaxPermSize=128m sets the size of 128 Mb.
Heap and non-heap memory usage telemetry is shown in the Memory tab:
Allocated and Used Memory
Allocated and used memory sizes are shown on the graphs for both heap and non-heap.
The allocated memory is an overall amount of memory allocated by the JVM, while used memory is the amount of memory which is actually in use.
Obviously, the allocated memory cannot be less than the used memory. The exact amount of allocated memory is determined by the JVM internal strategies.
Used Heap Memory: Live and Dead Objects
Used heap memory consists of live and dead objects.
Live objects are accessible by the application and will not be a subject of garbage collection.
Dead objects are those which will never be accessible by the application but have not been collected yet by the garbage collector. Such objects occupy the heap memory space until they are eventually collected by the garbage collector.
Note that Class list view in memory telemetry shows both live and dead objects. You may observe the decreasing number of objects when garbage collection occurs automatically or it is forced with the help of the corresponding toolbar button.
Object Sizes in Memory Snapshots: Shallow and Retained Sizes
All individual objects, as well as sets of objects have their shallow and retained sizes.
Shallow size of an object is the amount of allocated memory 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. 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.
Dead objects are shown only with shallow size, as they do not actually retain any other objects.
Read more about shallow and retained sizes.
Can't find your answer? Please refer to documentation and demos, ask your question in forum, or contact support.
As experience has shown, sometimes a sort of uncertainty may arise on the subject of Java Virtual Machine (JVM) memory structure and other related aspects such as sizes of various kinds of memory, live and dead objects, etc.
Shallow Size Vs Retained Size Android
In this article, we shall try to illuminate these issues to clear up the point.
Heap and Non-Heap Memory
The JVM memory consists of the following segments:
- Heap Memory, which is the storage for Java objects
- Non-Heap Memory, which is used by Java to store loaded classes and other meta-data
- JVM code itself, JVM internal structures, loaded profiler agent code and data, etc.
Heap
The JVM has a heap that is the runtime data area from which memory for all class instances and arrays are allocated. It is created at the JVM start-up.
The heap size may be configured with the following VM options:
- -Xmx<size> - to set the maximum Java heap size
- -Xms<size> - to set the initial Java heap size
By default, the maximum heap size is 64 Mb.
Shallow Vs Retained Size
Heap memory for objects is reclaimed by an automatic memory management system which is known as a garbage collector. The heap may be of a fixed size or may be expanded and shrunk, depending on the garbage collector's strategy.
Non-HeapAlso, the JVM has memory other than the heap, referred to as non-heap memory. It is created at the JVM startup and stores per-class structures such as runtime constant pool, field and method data, and the code for methods and constructors, as well as interned Strings.
Unfortunately, the only information JVM provides on non-heap memory is its overall size. No detailed information on non-heap memory content is available.
The abnormal growth of non-heap memory size may indicate a potential problem, in this case you may check up the following:
- If there are class loading issues such as leaked loaders. In this case, the problem may be solved with the help of Class loaders view.
- If there are strings being massively interned. For detection of such problem, Object allocation recording may be used.
If the application indeed needs that much of non-heap memory and the default maximum size of 64 Mb is not enough, you may enlarge the maximum size with the help of -XX:MaxPermSize
VM option. For example, -XX:MaxPermSize=128m sets the size of 128 Mb.
Heap and non-heap memory usage telemetry is shown in the Memory tab:
Allocated and Used Memory
Allocated and used memory sizes are shown on the graphs for both heap and non-heap.
The allocated memory is an overall amount of memory allocated by the JVM, while used memory is the amount of memory which is actually in use.
Obviously, the allocated memory cannot be less than the used memory. The exact amount of allocated memory is determined by the JVM internal strategies.
Used Heap Memory: Live and Dead Objects
Used heap memory consists of live and dead objects.
Shallow Size Vs Retained Size Conversion
Live objects are accessible by the application and will not be a subject of garbage collection.
Dead objects are those which will never be accessible by the application but have not been collected yet by the garbage collector. Such objects occupy the heap memory space until they are eventually collected by the garbage collector.
Note that Class list view in memory telemetry shows both live and dead objects. You may observe the decreasing number of objects when garbage collection occurs automatically or it is forced with the help of the corresponding toolbar button.
Object Sizes in Memory Snapshots: Shallow and Retained Sizes
All individual objects, as well as sets of objects have their shallow and retained sizes.
Shallow size of an object is the amount of allocated memory 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. 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.
Dead objects are shown only with shallow size, as they do not actually retain any other objects.
Read more about shallow and retained sizes.