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