Thursday, July 14, 2011

How to Solve java.lang.OutOfMemoryError: PermGen space

When developing Java web apps and deploying it in Jetty, you might encounter the following problem:

java.lang.OutOfMemoryError: PermGen space
Exception in thread "Timer-1" java.lang.OutOfMemoryError: PermGen space
^CJava HotSpot(TM) Server VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal SIGINT to handler- the VM may need to be forcibly terminated


pressing ctrl+c or ctrl+d wouldn't stop or shutdown the application so i had to use:

ctrl+z

doing this stops it, but the java process was still running in the background so i ran this:

ps aux|grep java

to confirm and saw something like this:

myuser 16947 2.1 13.6 768992 279720 pts/0 Z 09:40 1:07 /home/myuser/Desktop/jre1.6.0_11/bin/java -Dprogram.name=run.sh -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=/usr/jboss/lib/endorsed -classpath /usr/jboss/bin/run.jar org.jboss.Main -b 0.0.0.0 -c myuser

to kill the process you just run something like this:

kill -9 java-process-id-number

so in this case:

kill -9 16947

then if you run this again:

ps aux|grep java

you'll see this:

[java]

i found that when i close the terminal window and then open a new terminal and run this again:
Code:

ps aux|grep java

(SOURCE: http://nickhumphrey.net/showthread.php?p=3248)

1 comment: