Strange Maven out of memory error

2019-03-20 18:55发布

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?

6条回答
干净又极端
2楼-- · 2019-03-20 19:05

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>.

查看更多
唯我独甜
3楼-- · 2019-03-20 19:06

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

查看更多
贪生不怕死
4楼-- · 2019-03-20 19:12

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

查看更多
迷人小祖宗
5楼-- · 2019-03-20 19:19

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>
查看更多
闹够了就滚
6楼-- · 2019-03-20 19:27

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:

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.

查看更多
Fickle 薄情
7楼-- · 2019-03-20 19:32

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>
查看更多
登录 后发表回答