Method Area and PermGen
Asked Answered
P

4

21

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?

Phylissphyll answered 1/2, 2012 at 12:24 Comment(1)
Update : From java8 on words there is no PermGen, And all class, method, string interns stored in Metaspace. Link : karunsubramanian.com/websphere/…Shotgun
B
19

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.

Bellanca answered 1/2, 2012 at 12:31 Comment(0)
K
7

You could consider the "Method Area" a subset of "PermGen", as the permanent generation space does hold class defintions, but it also holds interned Strings and other bits of data unlikely to ever be discarded,

Kannry answered 1/2, 2012 at 12:27 Comment(4)
But it's not only PermGen subset, there can be a Method Area outside of PermGen space, right?Dominate
No, my understanding is that all that sort of data goes in PermGen.Kannry
Update: Interned strings are stored in main heap from Java 7 onwards. oracle.com/technetwork/java/javase/…Meiny
Update : From java8 on words there is no PermGen, And all class, method, string interns stored in Metaspace. Link : karunsubramanian.com/websphere/…Shotgun
S
4

Method Area is basically a non heap space like Stack which keeps class skeleton. skeleton includes static variables with values, constructors etc. The reflection operation are operated on this memory area. Perm is a memory space parallel to heap with keeps the binary code of current executing class.

Statue answered 6/7, 2013 at 9:6 Comment(0)
E
3

gives a pretty good idea which I haven't found elsewhere

Most people talk about Heap and Stack as equivalents, and as the main components, but Tai gives a picture-perfect explanation with superb images.

Edit: Link no longer works :(

Eulaheulalee answered 31/3, 2015 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.