Showing posts with label JVM. Show all posts
Showing posts with label JVM. Show all posts

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"

Thursday, June 25, 2009

How to Increase JVM(Java) Heap Size

If you're building a big project using ant/maven then your jvm heap size may not sufficient and give you a java.lang.OutOfMemoryError: PermGen space exception. Increasing of maven/ant heap size might not sufficient enough for that and an increase of jvm heap size might also needed. When you're starting an application through command line, you can do it by specifying
java -Xms32m -Xmx128m your_application
it will be a temporary increase of heap size and if you want to increase it permanently set the following environment variable as needed.
export _JAVA_OPTIONS="-Xms64m -Xmx128m"
-Xms64m is the startup size(64MB) and -Xmx128m is the maximum size(128MB)