JVM younger generation (young generation) older (old generation tenured) persistent generation (permanent generation) GC

Source: Internet
Author: User
Tags garbage collection
JVM younger generation (young generation) older (old generation tenured) persistent generation (permanent generation) GC

About JVM memory generation, see this post, forward

Link Address---thank you.

The total partition in the virtual machine is three generations: young Generation, Old Generation, and persistent (Permanent Generation). The persistent generation primarily stores the class information of the Java class, which is not related to the Java objects collected by garbage collection. The division of the younger generation and the old generation is more significant for garbage collection.

Young generations:

All newly generated objects are first placed in the younger generation. The goal of the young generation is to collect as quickly as possible those objects with short life cycles. The young generation is divided into three districts. One Eden area, two survivor districts (in general). Most objects are generated in the Eden area. When the Eden Zone is full, the surviving objects will be copied to the Survivor area (one of two), and when the survivor area is full, the surviving objects of this area will be copied to another survivor area, when the survivor is full, Objects that are copied from the first survivor area and that are still alive will be duplicated in the old Age zone (tenured). It should be noted that the two areas of the survivor are symmetrical and have no relationship, so the same area may exist at the same time from Eden copied objects, and from the previous survivor copied objects, and copied to the old quarter only from the first survivor to come over the object. Moreover, there is always an empty survivor area. At the same time, according to the program needs, the survivor area can be configured as multiple (more than two), which can increase the time of the object in the younger generation, reduce the possibility of being put into the old generation.

Old generation:

Objects that survived after n garbage collection in the younger generation will be placed in the old age. Therefore, it can be considered that older generations are storing objects with longer life cycles.

Persistent Generations:

Used to store static files, now Java classes, methods, and so on. The persistence generation has no significant impact on garbage collection, but some applications may dynamically generate or invoke some classes, such as Hibernate, at which point a large, persistent generation space is required to store the new class in these runs. The persistent generation size is set by-xx:maxpermsize=<n>.

Scavenge GC

In general, when a new object is generated and the Eden application space fails, the scavenge GC is triggered, GC is performed on the Eden Zone, the non-surviving objects are cleared, and the surviving objects are moved to the survivor area. Then tidy up the two districts of survivor. This method of GC is carried out on the young generation of the Eden area and does not affect the old generation. Because most objects start in the Eden area, and the Eden area is not very large, GC in the Eden area is frequent. Thus, it is generally necessary to use fast and efficient algorithms, so that Eden can be free as soon as possible.

Full GC

Organize the entire heap, including young, tenured and perm. The full GC is slower than the scavenge GC because it needs to be recycled for the entire pair, so it should be as low as possible. In the process of tuning the JVM, a large part of the work is to adjust the FULLGC. The full GC may be caused by the following reasons:

· The old generation (tenured) was written full

· Persistent generation (Perm) is full

· System.GC () is displayed call

• Dynamic changes in the domain allocation policy of the heap after the last GC

Look at a log:

At Java.util.concurrent.threadpoolexecutor$worker.runtask
(threadpoolexecutor.java:886)
at Java.util.concurrent.threadpoolexecutor$worker.run
(threadpoolexecutor.java:908)
at Java.lang.Thread.run (thread.java:662)
Exception in Thread "http-bio-17788-exec-74"
Java.lang.OutOfMemoryError:PermGen space
Exception in thread "http-bio-17788-exec-75"
Java.lang.OutOfMemoryError:PermGen space
Exception in thread "http-bio-17788-exec-76"
Java.lang.OutOfMemoryError:PermGen Space

It is obvious that the memory overflow of the old age indicates that there are too many static files under the container, such as compiled bytecode, JSP compiled into servlet, or jar package.

To resolve this problem, modify the JVM parameter permsize, permsize initial default is 64m.

JVM Memory Parameters

-vmargs-xms128m-xmx512m-xx:permsize=64m-xx:maxpermsize=128m
The-vmargs description is followed by the parameters of the VM, so the following are actually the parameters of the JVM
-xms128m JVM Initial allocation of heap memory
-XMX512M JVM Maximum allowable allocated heap memory, on demand
-xx:permsize=64m JVM Initial allocation of non-heap memory
-xx:maxpermsize=128m JVM Maximum allowable allocated non-heap memory, on demand

Heap and non-heap (non-heap) memory

According to the official statement, "Java virtual machines have a heap, the heap is a runtime data region, and all class instances and arrays of memory are allocated from here." The heap is created when the Java virtual machine is started. "" The memory outside the heap in the JVM is called non-heap (non-heap memory) ".
You can see that the JVM primarily manages two types of memory: heap and non-heap. In a nutshell, a heap is a Java-code memory that is left to developers to use, not heaps that the JVM has left for itself.


Original address:

Http://www.cnblogs.com/yaoyuan23/p/5587548.html

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.