Shallow vs. retained Heap

Source: Internet
Author: User

the two nouns of the shallow heap and retained heap are often encountered in Java memory analysis. This post is a translation of the shallow heap and retained heap help documentation in Eclipse Memory Analyzer.

The shallow heap is the memory consumed by an object. In an object, the reference property requires 32 or 64bits (depending on the OS architecture), the integer attribute requires 4 bytes, the Long property requires 8 bytes, and so on. Depending on the format of the heap dump, this size may be adjusted (for example, aligned to 8 bytes, etc.) to a model that is more conducive to the actual memory consumption of the VM.

The retained set of X is the collection of all objects that will be recycled by GC when x is garbage collected.

The retained heap of x refers to the shallow size of all objects in the retained set of X and, for example, memory that is surviving because of X.

Generally, the shallow heap of an object is the size of the object in the heap, and the retained size of the same object is the sum of the heap memory that will be freed when the object is garbage collected.

From the leading set angle, retained set is a collection of objects that are freed because leading set becomes unreachable. The leading set can be any object of a particular class, or an object of all classes loaded by a particular class loader, or a combination of arbitrary objects. The retained set includes objects in the leading set and all objects that can only be accessed through objects in leading set. Retained size is the total heap size of all objects in the retained set.

Shallow vs. retained Heap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.