Tuesday, August 25, 2009

java.lang.OutOfMemoryError: PermGen space

Every time we make a new build, we redeploy it, and after a few such redeployments it throws this error.

And we need to restart JBOSS.

As we are seeing this error very frequently, I had googled it and found some information on this.

Here are the links to this information.

These links also say that after a few redeployments, JBOSS console shows up this error.

http://blog.yannis-lionis.gr/?p=8

http://www.freshblurbs.com/explaining-java-lang-outofmemoryerror-permgen-space

http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html#1.1.%20Generations|outline

Excerpt from links:

In Sun JVM, garbage-collection of Java Heap is managed in generations (memory segments holding objects of different ages- Young Generation, Tenured Generation and Permanent Generation). Garbage collection algorithms in each generation are different.

The permanent generation holds data needed by the virtual machine to describe objects that do not have equivalence at the Java language level. For example objects describing classes and methods 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

We can increase the PermGen (Permanent Generation) size in JVM, but this just delays the error and cannot get rid of it.

To tackle this, posts suggest two options:

  1. Restart the JBOSS every time we redeploy.
  2. Change the Sun JVM to some other JVM.

Links also suggests JRockit JVM as it doesn’t have a PermGen area and can never throw this error.

No comments: