Undo permanent generation in Java 8, introducing meta-space

Source: Internet
Author: User

To undo a permanent generation, introduce meta-space:

In JDK 1.8, HotSpot has no space for "PermGen space" and is replaced by something called metaspace (meta space).

The string constant pool has been removed from the permanent generation in Java7, and an area is opened in the Java Heap (heap) to hold the string constant pool. In Java8, there is no permanent generation, and the method area is placed directly in a local memory area that is not connected to the heap, and this area is called the meta-space.

After the permanent generation is removed, there is no permanent memory overflow error, and there is no such thing as leaking data moving to the swap area. The end user can set a maximum free space for the meta space, and if not set, the JVM automatically increases the capacity of the meta space dynamically based on the metadata size of the class.

This change is necessary because it is difficult to tune the permanent generation. Metadata in a permanent generation may move as each full GC occurs.

PermGen (permanent generation) :

"PermGen space" means a permanent generation. The method area and the "PermGen space" have the essential difference. The former is a specification of the JVM, and the latter is an implementation of the JVM specification, and only the HotSpot has "PermGen space", while for other types of virtual machines, such as JRockit (Oracle), J9 (IBM), there is no "PermGen space". Because the method area primarily stores information about classes, it is relatively easy to generate a persistent memory overflow for dynamically generated classes. The most typical scenario is that the JSP page is much more prone to permanent memory overflow.

A permanent garbage collection is bound to a garbage collection in the old age, and once one of the areas is full, the two zones are garbage collected.

metaspace (meta space) :

In fact, the removal of the permanent generation of work started from JDK1.7. In JDK1.7, portions of data stored in a permanent generation have been transferred to the Java heap or to the Native heap. However, the permanent generation still exists in JDK1.7 and is not completely removed, for example, the symbolic reference (Symbols) is transferred to the native heap; the literal (interned strings) is transferred to the Java heap; The static variable (class Statics) of the classes is transferred to the Java heap.

The nature of meta-space is similar to permanent generation, which is the implementation of the method area in the JVM specification. However, the biggest difference between meta-space and permanent generation is that the meta-space is not in the virtual machine, but rather uses local memory . Therefore, by default, the size of the meta-space is limited only by local memory, but you can specify the size of the meta-space by using the following parameters

Why has the permanent generation been removed from the hotspot JVM?

1. Because permanent generation memory is often insufficient or memory leaks occur, it causes annoying java.lang.OutOfMemoryError:PermGen (very common in Java Web development).

2. Removing the permanent generation can facilitate convergence between the Hotspot JVM and the JRockit VM, because JRockit does not have a permanent generation.

3, the permanent generation of tuning is very difficult.

Why to introduce meta-space:

1, the string exists in the permanent generation, prone to performance problems and memory overflow.

2, classes and methods of information, such as difficult to determine its size, so the size of the perpetual generation is difficult to specify, too small prone to permanent overflow, too large will easily lead to old age overflow.

3, the permanent generation will bring unnecessary complexity to the GC, and the recovery efficiency is low.

4. Oracle may merge hotspot with JRockit.

Undo permanent generation in Java 8, introducing meta-space

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.