References in Java

Source: Internet
Author: User
The JVM is based on the accessibility analysis algorithm to find the objects that need to be recycled, to determine whether the object's survival status is related to the reference.

Before JDK1.2, this design is very simple: the state of an object is only referenced and not referenced in two different ways.

Such partitioning is not very friendly to garbage collection because there are always some objects that are in the state of the two.

So four new states have been added after 1.2 for finer-grained partitioning of referential relationships:

Strong reference (Strong Reference): This object is most common, such as A a = new A(); this is a typical strong reference, such a strong referential relationship can not be garbage collection. Soft references (Soft Reference): Such references indicate useful but not necessary objects that need to be recycled before garbage collection occurs. Weak references (Weak Reference): This is a reference relationship that is weaker than a soft reference and is a non-mandatory object. When garbage is collected, objects like this are recycled regardless of whether the current memory is sufficient. Virtual reference (Phantom Reference): This is the weakest reference relationship and cannot even get the object by reference, its only function is to be notified when it is recycled.

References in Java

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.