I am currently trying to build my project using hudson to call maven. I keep getting the problem of out of memoery error. I set the xmx and xms in all environmental variable, hudson configuration and hudson project config. I set the xmx to 1500 mb which should be more than enough as the whole project is less than 1000mb. the machine used to build the project is a server where the maven repo for the team is stored.
Anyone have come acrossed the same problem? Any idea of how it happen?
If you get an OOM during the tests, then you must tell the surefire plugin to fork a new VM for the tests:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Xms512m -Xmx512m</argLine>
</configuration>
</plugin>
Thank you everyone for answering my question. I have solved the problem by making a heap dump and analysing it. I make a heap dump by passing the following VM args:
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=E:/
.
I then use Eclipse Memory Analyser to open the java_pidxxxxx.hprof
file.
I found out that the listener we used to catch the exception cannot catch the exception. So the exception sort of stays in the VM and hence, memory leak!
Thanks again for all the answers
Do make sure you have enough MaxPermSpace. I've run into problems where the memory allocated to the JVM was sufficient, but the OutOfMemoryError was due to the PermSpace being exhausted. That is not too uncommon when we are dealing with compiling code--particularly if it is compiling code, throwing it away and compiling again. For more information about tuning the garbage collector (and memory) check out these references:
- Tuning Garbage Collectionwith the 5.0 Java TM Virtual Machine
- Memory Management in the Java HotSpot™ Virtual Machine
In the Memory Management Whitepaper on pages 16-17, it outlines possible reasons for OutOfMemoryErrors. Another defense is to fork the maven process and/or the compiler.
Assuming you are using Sun's JDK, then in Hudson / Manage Hudson / Maven Project Configuration / Global MAVEN_OPTS set the following: -Xmx512m -XX:MaxPermSize=256m
Hudson kicks off a separate task to run Maven jobs. You will need to configure the increased memory in the MAVEN_OPTS text field. The field is located in individual job configuration windows.
Edit: Following up with your comments. Are you by chance forking your compile, running it in a separate execution or forking your junit testing.
Try in your compiler configuration (assuming you have one):
<maxmem>512m</maxmem>
i got the same problem. when trying to instrument the code, hudson (or JVM) throw java out of memory. The solution is: in the configuration of plugin cobertura-maven-plugin
, use <maxmem>512m</maxmem>
.