Object references in the Java language fall into the following categories: Strong references, soft references, weak references, virtual references
Strong reference is usually the most commonly used reference, when the memory space is low, the Java virtual machine would rather throw a outofmemoryerror error, so that the program terminates abnormally, also will not be free to recycle strong reference objects to solve the problem of insufficient memory.
If an object has only a soft reference, the memory space is sufficient, the garbage collector will not recycle it, and if the memory space is low, the memory of those objects is reclaimed.
Objects that have only weak references have a more ephemeral lifecycle. When the garbage collector thread scans the area of memory it governs, it reclaims its memory whenever it discovers an object that has only a weak reference, regardless of whether the current memory space is sufficient or not.
Virtual reference, this reference is not commonly used, the main purpose is the result of referencing the associated object, to implement the object reference relationship tracking. A virtual reference does not determine the life cycle of an object. If an object holds only a virtual reference, it is likely to be reclaimed by the garbage collector at any time, as without any reference.