References to Java virtual machines

Source: Internet
Author: User
Strong reference: similar to: Object A=new object (); Such a reference, as long as a strong reference exists, the garbage collection period will never reclaim the referenced object, eg: here the new Oject (). Soft References: Some of the objects that are also useful, but are not required, are objects that are associated with soft references, which will be included in the collection and two recycled before the system is about to have a memory leak, and if these objects are reclaimed or out of memory, a memory overflow occurs and a memory overflow exception is run out. After jdk1.2, the SoftReference class is provided to implement the soft reference. virtual references: called Phantom references, Phantom references, which are the weakest way to refer, whether an object has a virtual reference that has no effect on its lifetime, and cannot obtain any instances by a virtual reference. The sole purpose of setting a virtual reference is to receive a notification of the system when the object is recycled. Two tokens from birth to death: For the first time, the object is concatenated with the search discovery without any reference chain, and the objects are marked and filtered once, and the filter condition is whether the object is necessary to execute the Finalize () method when the object does not overwrite finalize (). Method or Finalize method has been called by the virtual machine, the virtual machine will assume that neither of these situations is necessary. When an object needs to execute a Finalize method, he will be put into a queue named F-queue, and later the virtual opportunity automatically starts a low-priority thread finalizer executes it, which refers to a virtual opportunity to trigger him, but does not commit to executing it, Because if an object is executed slowly or cyclically in finalize, then it is possible that f-queue is waiting, even causing the entire recovery system to crash, Finalize is the last chance for an object to flee, and later the GC will mark the object for a second time. If the object establishes a reference relationship in the Finalize method with any object on the reference chain, such as copying itself this to a class or variable. The Finalize method of any object is called only once by the system, and an object can only save itself once

References to Java virtual machines

Related Article

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: 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.