Thursday, April 28, 2011

How to increase JVM Heap Size and Perm Gen space

If you are dealing with applications which have large code bases, then you might quickly run out of Java memory. Probably you might get either java.lang.OutOfMemoryError: PermGen or java.lang.OutOfMemoryError: Java heap space. In order to fix that, just having sufficient memory in your machine is not sufficient. So you need to increase the JVM Heap size and Permanent Generation space.

Setting the following environment variable before starting your application, you can increase them easily.

Unix
export JAVA_OPTS="-Xms512m -Xmx1024m -XX:MaxPermSize=1024m"

Windows
set JAVA_OPTS="-Xms512m -Xmx1024m -XX:MaxPermSize=1024m"

2 comments: