My new website on Artificial Intelligence and Machine Learning www.aimlfront.com

PermGen Space vs Heap Space

Java Heap space:

The JVM's heap stores all the objects generating by a running Java program. Java uses the new operator to create objects and memory for new objects is allocated on the heap at run time. Garbage collection is the mechanism of automatically freeing up the memory contained by the objects that are no longer referenced by the program.

Java Perm space:

Perm space is used to keep information 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.

One small thing to remember is that "=" is used to separate parameter and value while specifying size of perm space in heap while "=" is not required while setting maximum heap size in java, as shown in below example.

     

export JVM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"




REASONS and SOLUTIONS FOR PERMSPACE AND HEAP SPACE ERROR

     »  Reasons for OutOfMemoryError or PermGen Space Error??

     »  How to resolve OutOfMemoryError or PermGen Space Error??