Memory distribution in JavaIn the JVM, memory is organized in terms of generational.Among them, heap memory is divided into young generation and old generation, non-heap memory is mainly permanent area, mainly used for storing some kinds of metadata, constant pool and other information. And the younger generation is divided into two kinds, one is Eden area, the other is two size equivalent survivor area. The reason that Java memory is organized on a generational basis is based on a "weak hypothe
area is "thread-private" memory. Shared data areaA) heapfor most applications, the Java heap (Java heap) is the largest piece of memory managed by a Java virtual machine. The Java heap is a piece of memory that is shared by all threads and created when the virtual machine is started. The only purpose of this area of memory is to hold object instances where almost all of the object instances are allocated memory. According to the Java Virtual Machine specification, the Java heap can be in a phy
references (Soft Reference), weak references (Weak Reference), virtual references (Phantom Reference) 4 species, these 4 kinds of reference strength gradually weakened.
A strong reference is a common reference in program code, such as "Object obj = new Object ()", as long as a strong reference exists, and the garbage collector never reclaims the referenced object.
Soft references are used to describe objects that are useful but not neces
The Java heap is described as follows:Memory consists of perm and heap. where heap = {old + NEW = {Eden, from, to}}The JVM memory model is divided into two chunks:New Generation: The newly created object of the program is to allocate memory from the Cenozoic, and the Cenozoic is made up of Eden Space and two blocks of the same size survivor space (usually called S0 and S1 or from and to), which can be specified by the-XMN parameter to the Cenozoic size. You can also adjust the size of Eden space
for Java GC details, see
Summary: Three kinds of memory recovery mechanism, reference counting method, tracking method and generational method. There are multiple classifications for the tracking method, and the GC mechanism for different platforms varies, mark one, and the back mind map
C + + does not have garbage collection, but it provides the API (malloc ()/Free () new ()/delete)), requests memory to t
replication cost is relatively small. At the same time, the corresponding memory can be organized after the replication, without the "Fragmentation" problem. Of course, the disadvantage of this algorithm is also obvious, that is, it requires two times of memory space.
Mark-compact ):
This algorithm combines the advantages of "tag-clear" and "copy" algorithms. It is also divided into two phases. In the first phase, all referenced objects are marked from the root node. In the second stage, the
The garbage collection mechanism is a dynamic storage allocation solution. It automatically releases allocated memory blocks that are no longer needed by the program. The process of automatic memory recovery is called garbage collection. The garbage
memory space to allocate when the program runs, the program will crash. In general, the memory space that is allocated but cannot be recycled is called "Memory leakage (memory leaks )".
The potential danger of the above program design is not allowed in a rigorous and secure language such as Java. However, the Java language neither limits the freedom of programmers to write programs nor removes part of declared objects (otherwise it is not an object-oriented programming language ), the best solu
IntroductionThe garbage collection technology was not the first in the Java language, and the 1960 birth of the Lisp at MIT was the only language that really used memory dynamic allocation and garbage collection techniques. The three issues to consider in the garbage
English Original: Maoni Stephens, compilation: Zhao Yukai (@ Jade Kai Sir)
The CLR garbage collector divides objects by the amount of space they occupy. Large objects and small objects are handled in a very different way. For example, memory defragmentation-the cost of moving large objects in memory is expensive, so let's look at how the garbage collector handles large objects, and how large objects have a
Click to enter _ more _java thousand ask1. What are the ways of Java garbage collection?The so-called garbage collection method, refers to the JVM provides several different garbage collector, different garbage collector when
Document directory
(1) do not explicitly call system. GC ()
(2) minimize the use of temporary objects
(3) it is best to explicitly set the object to null when it is not used.
(4) Try to use stringbuffer instead of string to accumulate the string (For details, refer to the string and stringbuffer in another blog article in Java)
(5) You can use basic types such as int and long to remove integer and long objects.
(6) Use as few static object variables as possible
(7) time when the dispers
the reference chain (Reference Chain), when an object to the GC roots no reference chain can be reached, it is called the object is unreachable (not referenced), that is, can be recycled by GC. As shown in the following:[Accessibility algorithm determines whether objects can be recycled] [1]
Whether it's a reference counter or a accessibility analysis, determining whether an object survives is a reference! So, how do you define a reference t
1. The meaning of garbage collectionin theJava, the memory becomes garbage when no object reference points to the memory that was originally assigned to an object. JVMa system-level thread automatically frees the block of memory. Garbage collection means that the object that the program no longer needs is"Useless Infor
detected. During the final concurrency cleanup (concurrent sweep) phase, the garbage collection process is actually executed. Other threads are still executing during garbage collection execution. The system outage time during GC is very short due to the way the CMS GC is executed. The CMS GC is also known as a low la
JVM garbage Collection algorithm (most complete)The following is the memory model of the JVM virtual Runtime:1. Method area Perm (permanent generation, non-heap)2. Virtual Machine stack3. Local method Stack (native method)4. Heap5. Program counter1 The first question is: How does the JVM know that those objects need to be recycled?At present, two kinds of identification algorithms, three recovery algorithms
I. The significance of garbage collectionIn C + +, the memory occupied by an object is occupied until the end of the program and cannot be assigned to other objects until it is explicitly released, whereas in Java the memory becomes garbage when there is no object reference to the memory originally assigned to an object. A system-level thread of the JVM automatically frees the block of memory.
Transfer from http://www.cnblogs.com/kaituorensheng/p/4449457.htmlIn Python, in order to solve the problem of memory leaks, object reference counts are used, and automatic garbage collection is implemented based on reference counting. memory leaks: also known as "storage leaks." A dynamically opened space with dynamic storage allocation functions is not released after use, resulting in the memory unit bein
cost is small, and replication can be done in the past, and there is no "fragmentation" problem. Of course, the disadvantage of this algorithm is also very obvious, is to need twice times the memory space.Labeling-Finishing (mark-compact):This algorithm combines the advantages of the "mark-clear" and "copy" two algorithms. It is also divided into two stages, the first phase marks all referenced objects starting from the root node, the second stage traverses the entire heap, clears the unlabeled
The CLR Garbage Collector divides Objects Based on the occupied space. The processing methods for large and small objects are quite different. For example, memory fragmentation-the cost of moving large objects in the memory is expensive. Let's look at how the Garbage Collector handles large objects and what potential impact large objects have on the procedure. Large Object heap and
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.