What is perm space?
Asked Answered
S

10

91

While learning about java memory profiling, I keep seeing the term "perm space" in addition to "heap." I know what the heap is - what's perm space?

Synchroscope answered 14/8, 2009 at 18:35 Comment(2)
Java 8 has completely removed this concept and moved into MetaspaceAideaidedecamp
Reference explained well here youtube.com/watch?v=PUUJ4rNpRhURembrandt
S
106

It stands for permanent generation:

The permanent generation is special because it holds meta-data describing user classes (classes that are not part of the Java language). Examples of such meta-data are objects describing classes and methods and they are stored in the Permanent Generation. Applications with large code-base can quickly fill up this segment of the heap which will cause java.lang.OutOfMemoryError: PermGen no matter how high your -Xmx and how much memory you have on the machine.

Swahili answered 14/8, 2009 at 18:39 Comment(2)
Andrew , I am just curious to know about what could be size of PerGen ?Allowable
Just curious if permgen is a part of heap memory (as stated in this answer) or it is off-heap (as stated in this answer - https://mcmap.net/q/15882/-java-heap-terminology-young-old-and-permanent-generations).Sapowith
M
27

Perm space is used to keep informations for loaded classes and few other advanced features like String Pool(for highly optimized string equality testing), which usually get created by String.intern() methods. As your application(number of classes) will grow this space shall get filled quickly, since the garbage collection on this Space is not much effective to clean up as required, you quickly get Out of Memory : perm gen space error. After then, no application shall run on that machine effectively even after having a huge empty JVM.

Before starting your application you should java -XX:MaxPermSize to get rid of this error.

Malang answered 24/10, 2009 at 9:48 Comment(1)
String pool gets shifted to heap space since java 7.Leukemia
D
20

Simple (and oversimplified) answer: it's where the jvm stores its own bookkeeping data, as opposed to your data.

Doughy answered 14/8, 2009 at 18:42 Comment(0)
J
17

Perm Gen stands for permanent generation which holds the meta-data information about the classes.

  1. Suppose if you create a class name A, it's instance variable will be stored in heap memory and class A along with static classloaders will be stored in permanent generation.
  2. Garbage collectors will find it difficult to clear or free the memory space stored in permanent generation memory. Hence it is always recommended to keep the permgen memory settings to the advisable limit.
  3. JAVA8 has introduced the concept called meta-space generation, hence permgen is no longer needed when you use jdk 1.8 versions.
Jennifer answered 6/3, 2016 at 6:39 Comment(0)
M
5

The permgen space is the area of heap that holds all the reflective data of the virtual machine itself, such as class and method objects.

Moonshine answered 14/8, 2009 at 18:40 Comment(0)
G
3

It holds stuff like class definitions, string pool, etc. I guess you could call it meta-data.

Guillermoguilloche answered 14/8, 2009 at 18:41 Comment(0)
S
3

Permgen space is always known as method area.When the classloader subsystem will load the the class file(byte code) to the method area(permGen). It contains all the class metadata eg: Fully qualified name of your class, Fully qualified name of the immediate parent class, variable info, constructor info, constant pool infor etc.

Sipper answered 28/6, 2017 at 16:2 Comment(0)
S
2

What exists under PremGen : Class Area comes under PremGen area. Static fields are also developed at class loading time, so they also exist in PremGen. Constant Pool area having all immutable fields that are pooled like String are kept here. In addition to that, class data loaded by class loaders, Object arrays, internal objects used by jvm are also located.

Sedgewinn answered 6/2, 2017 at 15:14 Comment(0)
R
1

PermGen Space stands for memory allocation for Permanent generation All Java immutable objects come under this category, like String which is created with literals or with String.intern() methods and for loading the classes into memory. PermGen Space speeds up our String equality searching.

Rounds answered 7/10, 2013 at 6:14 Comment(0)
A
1
  • JVM has an internal representation of Java objects and those internal representations are stored in the heap (in the young generation or the tenured generation).
  • JVM also has an internal representation of the Java classes and those are stored in the permanent generation

enter image description here

Adames answered 23/4, 2020 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.