Presumably many friends of Oom (outofmemory) This error is not unfamiliar, and when encountered this error how to effectively solve the problem? Today we are going to say how to use soft references and weak references to effectively resolve oom
The Java 2 platform introduces the java. Lang. Ref package, including classes that allow you to reference objects without leaving them in memory. These classes also provide limited interaction with the garbage collector. Peter Haggar analyzes
Before looking at the first time in an in-depth understanding of the Java Virtual Machine, I contacted the relevant noun, but did not understand that the object obj = new Object () is a strong reference when it is similar to this operation. Strong
Preface overviewIn previous versions of JDK1.2, when an object was not referenced by any variable, the program could no longer use the object. This is like in daily life, after buying a certain item from the store, if it is useful, keep it, or throw
Today interviewed a company's Java development intern, was asked a question: How to deal with the memory leaks in Java, to ensure that the Java Virtual Machine memory will not be blown out, then actually feel that the interviewer's problem is a bit
1. Strong referencesUsually when we program, for example: Object Object=new object (); That object is a strong reference. If an object has a strong reference, it is similar to essential necessities, and the garbage collector will never recycle it.
1, Java Memory management is divided into memory allocation and memory recovery, do not need the programmer's responsibility.2, garbage collection mechanism is mainly to see if the object has a reference to the object.References to Java objects
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. When there is not enough memory space, the Java virtual Machine prefers to
In versions earlier than JDK, when an object is not referenced by any variable, the program will no longer be able to use this object. That is to say, the program can use the object only when it is reachable. This is like in daily life, after buying
Strong references, soft references, and weak references in JavaStrong references in Java, soft references to SoftReference, weak references to WeakReference, and virtual referencesThere are four types of references in Java:1. Strong referenceWe
Understanding weak references in Java
Not long ago, I interviewed some candidates for senior Java development engineers. I often interview them and say, "Can you introduce me to some weak references in Java ?", If the subject says, "Well, is it
strong, soft, weak, and virtual references to objectsin previous versions of JDK 1.2, if an object was not referenced by any variable, the program could no longer use the object. That is, only the object is in the accessible (reachable) state before
Java has divided object references into four levels since jdk1.2, so that the program can control the object lifecycle more flexibly. The four levels are from high to low: strong reference, soft reference, weak reference, and virtual reference.
Here
Java begins with the JDK1.2 version, dividing the object's references into four levels, allowing the program to control the object's lifecycle more flexibly. These four levels, from highest to lowest, are: Strong references, soft references, weak
Strong references in Java, soft reference softreference, weak reference weakreference, virtual referenceThere are four types of references in Java:1. Strong referencesThe most common reference we use. Strong references are the most commonly used
Java from JDK1.2 version begins by dividing the object's references into four levels, giving the program more flexibility in controlling the object's life cycle. These four levels are high to low in order: Strong references, soft references, weak
How Java effectively avoids oom: good at using soft and weak referencesPresumably many friends will not be unfamiliar with the error of Oom (OutOfMemory), and when encountering this kind of mistake how to solve this problem effectively? Today, let's
How Java effectively avoids oom: good at using soft and weak referencesPresumably many friends will not be unfamiliar with the error of Oom (OutOfMemory), and when encountering this kind of mistake how to solve this problem effectively? Today, let's
Four types of references in JavaToday, look at the code, there is a class java.lang.ref.SoftReference the younger brother to God, imagine, touch Java has been 3 years, wow, even lang package below the class are not understand, how to mix. Later
Starting with the JDK1.2 version, Java is dividing the object's references into four levels, giving the program more flexibility in controlling the object's life cycle. These four levels are high to low in order : Strong references, soft references,
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.