Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method Area and PermGen

Tags:

I was trying to understand the memory structure of HotSpot JVM and got confused with the two terms "Method Area" and "PermGen" space. The docs I referred to say that Method Area contains the definition of classes and methods including the byte code. Some other docs say that they are stored in the PermGen space.

So can I conclude that these two memory areas are same?

like image 654
Ratheesh P Kumar Avatar asked Feb 01 '12 12:02

Ratheesh P Kumar


People also ask

Is method area and Metaspace same?

The method area, also known as Permanent Generation (PermGen), is considered a part of Heap memory, logically, although the simpler implementations of JVM may choose not to garbage-collect it. However, Java 8 removes the PermGen space and introduces a new native memory space named Metaspace.

What is method area?

Method Area. The Java Virtual Machine has a method area that is shared among all Java Virtual Machine threads. The method area is analogous to the storage area for compiled code of a conventional language or analogous to the "text" segment in an operating system process.

What is PermGen size?

PermGen is the memory area for storing class data like static variable,byte code and etc. By default 64 Mb is allocated for PermGen.

What is PermGen?

PermGen (Permanent Generation) is a special heap space separated from the main memory heap. The JVM keeps track of loaded class metadata in the PermGen. Additionally, the JVM stores all the static content in this memory section.


1 Answers

You should take a look at Java Memory Types and optionally at this doc about the Garbage Collection in Java. The latter is very verbose and both are useful.

Actually the Method area is a part of the Permanent Generation:

A third generation closely related to the tenured generation is the permanent generation. The permanent generation is special because it holds data needed by the virtual machine to describe objects that do not have an equivalence at the Java language level. For example objects describing classes and methods are stored in the permanent generation.

like image 155
xea Avatar answered Oct 09 '22 10:10

xea