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?

- 9,100
- 13
- 47
- 76
-
Are you running the project from inside netbeans or starting it with maven from the command line? – beerbajay Jun 08 '12 at 13:50
-
I am running it from Netbeans – Denees Jun 08 '12 at 13:51
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:
- Open up tomcat/bin/catalina.sh
- 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"
- Save and exit , restart Tomcat

- 16,161
- 49
- 147
- 202
-
-
-
Ok, this is a solution, but not for long, at the 7th run I have the same exception. I profiled my application and find no Java leaks, so whats the problem at all? Is the maven who is so fickle? – Denees Jun 11 '12 at 13:12
-
@DenisHoss Okay,change both PermSize and MaxPermsize to 512m, and boot it up again(they are 256m atm). – Jaanus Jun 11 '12 at 13:52
-
Ok, I did that, I'll see how it will be now, and come back with an answer – Denees Jun 11 '12 at 14:12
-
How I told before, the solution is temporary. I have the same output after few runs. – Denees Jun 12 '12 at 07:33
-
@DenisHoss Do you use somekind of surefire plugin, as mentioned here? http://vatsakatta.blogspot.com/2012/03/maven-and-out-of-memory-permgen-space.html – Jaanus Jun 12 '12 at 07:50
-
only maven-compiler-plugin, maven-war-plugin and maven-dependency-plugin – Denees Jun 12 '12 at 08:20
-
it is not java leaks which is the issue it is static references to unlinked code which you dont have access to in order to clean up. This question is old so i hope you found the solution, it is a long slaught and usually you cant do anything about it unless you stop using the .jar file which is causing the problem and go for another solution. – pengibot Jul 11 '12 at 08:32
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.

- 1,492
- 3
- 15
- 35
-
My project have only the struts, spring, hibernate dependencies and 2 jsp's :), it is a test project – Denees Jun 08 '12 at 14:02
-
it will be one of them then, probably where you call one of their classes/methods using a static reference. it usually occurs when reloading it from the server, i got it with log4net a while ago and had to stop using the static call i was calling to stop this. it is one of the most annoying and hard to find errors in java i find, for a test project i wouldnt waste time trying to find the cause, if it was a production project you would have to as updating your software could cause problems – pengibot Jun 08 '12 at 14:05
-
It isn't a maven issue. By all means look into it. A way to not get it to occur is to simply remove your .war file before adding your new .war file as that way the references should be removed 99% of the time from your server... where if you try and do a straight update you will probably hit this problem a lot more. – pengibot Jul 11 '12 at 08:30
-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

- 1
- 1

- 46,889
- 11
- 103
- 119