A detailed introduction to Java reference Types _java

Source: Internet
Author: User

• Strong reference (finalreference), in Java, a bit like C + + pointers, by reference, you can manipulate the objects in the heap. Strong references have the following characteristics:
1. Strong reference can directly access the target object;
2. The object pointed by a strong reference will not be reclaimed by the system at the time of the task;
3. Strong references can lead to memory leaks.
• Soft Reference (softreference), a soft reference object that the garbage collector determines whether to clear the object when responding to memory needs. An object holding a software reference will not be quickly recycled by the JVM, as long as there is enough memory, the software reference may survive in memory for a long time, soft reference objects are most commonly used to realize memory-sensitive caching;
• Weak reference (weakreference), weak reference is a relatively weak reference type, when the system GC, as long as the discovery of weak references, regardless of the system heap memory is sufficient, will be the object recycling;
• Virtual Reference (phantomreference), a virtual reference is the weakest of all references, and an object holding a virtual reference is almost the same as not being referenced and may be reclaimed by the garbage collector at any time.

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.