Java four types of references include strong references, soft references, weak references, and virtual references.Strong references:The garbage collector will never recycle as long as the reference existsObject obj = new Object ();
The
In Java strong reference, soft reference, weak reference and Virtual Reference original link: http://aaronfu.net /? P = 9995
Since jdk1.2, the object reference is divided into four levels, so that the program can control the object lifecycle more
Strong references, soft references, weak references, virtual referencesLet's talk about the garbage collection mechanism gabagecollection:GC is the meaning of garbage collection (gabagecollection). Like Java, the Android system is also powered by GC
The so-called memory leak, is actually the object in the time of the recovery is not properly recycled, the memory of these wild pointers. So it's important to understand these kinds of citation patterns and use it with the Great God's blog.Reprint:
1. Strong citation (Strongreference)Strong references are the most commonly used references. If an object has a strong reference, the garbage collector will never recycle it. As follows:Object o=New object (); // Strong ReferencesWhen there is
1. Strong citation (Strongreference) Strong references are the most commonly used references. If an object has a strong reference, the garbage collector will never recycle it. As follows: Object O=new object (); Strong references When there is not
1, first lead me to meet a problem (I think first write the question, so the impression deeper engraved a bit):Android Java layer when calling local JNI code, will maintain a local reference table (maximum length is 512), general JNI function call
As we all know, Java is the JVM responsible for the allocation and recycling of memory, which is its advantage (easy to use, the program no longer like using C as the memory), but also its shortcomings (not flexible). In order to solve the problem
As we all know, Java is the JVM responsible for the allocation and recycling of memory, which is its advantage (easy to use, the program no longer like using C as the memory), but also its shortcomings (not flexible). In order to solve the problem
Knowing the concepts of weak references and soft references are different from how they are used, and referencing classes play an important role in the process of garbage collection. We all know that the garbage collector reclaims the memory of
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.