Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven "Exception in thread "http-bio-8080-exec-32" java.lang.OutOfMemoryError: PermGen space"

I made a project in NetBeans under Ubuntu 11.10 with Struts2 + Spring and Hibernate frameworks. The first run is ok, but when I run it for the second or third time I keep getting this exception. Without Maven all goes well. I installed maven with apt-get install, and yes I added this line export MAVEN_OPTS=-Xmx512m in usr/bin/mvn, but without luck. How to get a better performance from it?

like image 651
Denees Avatar asked Jun 08 '12 13:06

Denees


3 Answers

You should add this line:

export MAVEN_OPTS="-Xmx512M -XX:MaxPermSize=512M" 

Note that some users have reported that the double quotes give problems, hence you might want to use:

export MAVEN_OPTS=-Xmx512M -XX:MaxPermSize=512M 

EDIT:

Since you are using Tomcat, use this:

  1. Open up tomcat/bin/catalina.sh
  2. add this line to the JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
  3. Save and exit , restart Tomcat

More information here...

like image 52
Jaanus Avatar answered Nov 03 '22 00:11

Jaanus


permgen space usually throws this error when objects do not clear up their memory properly. usually cause of 'islands' which is objects with references still pointing to them but you as the programmer dont have access to these references because they live outside your space. you are probably using a library which is causing this problem, and it probably wont go away till you stop using this library. as for which library, i am not sure, there are plenty of articles explaining how to find this out, but it is a chore and may take a while unless you are lucky. memory profilers can give some idea.

good explanation article

like image 39
pengibot Avatar answered Nov 03 '22 00:11

pengibot


-Xmx512m won't help you, because you are increasing the heap space. You are run out of PermGen space, not of heap space.

Try to increase the PermGen space and put some flags for garbaging it. Here is more information: Recurring "PermGen" in Tomcat 6

like image 42
Petar Minchev Avatar answered Nov 03 '22 01:11

Petar Minchev