Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven fails with error 'Process exited with code 137' [duplicate]

Tags:

java

maven

Maven fails with scarce 'Process exited with code 137' in logs.
What could be possible reasons of the critical error and what could be the fix?

like image 966
Mike Avatar asked Dec 07 '22 23:12

Mike


2 Answers

Just to note, I eventually found that the problem was too much memory being allocated, not too little.

When running the job on a machine with 2GB of memory and setting the max heap size to 2GB, the build eventually failed with status 137. However when setting the job to 1GB maximum (e.g. -Xmx1g -Xms512m), the build succeeded.

This kind of makes sense, because the JVM will freely increase its memory up to the maximum heap size, but if there's not enough real memory, the OS will kill the process. However, if you reduce the max heap size, the JVM won't try to increase its memory so highly, so the OS won't worry about it enough to kill it.

Furthermore, I was using GWT which forks a separate process for compilation, and the arguments have to be specified as an extraJvmArgs element within gwt-maven-plugin configuration, not in MAVEN_OPTS.

like image 33
Adam Burley Avatar answered Feb 23 '23 00:02

Adam Burley


Process was killed by Linux OOM Killer because you are low on resources on the machine.

Give machine more memory and/or swap or reduce memory footprint of your process which is directly impacted by jvm default Xmx, which most probably is far from what jvm actually need.

Give it additional java command line options

-Xmx256m -XX:MaxPermSize=512m

or configure system variable

MAVEN_OPTS=-Xmx256m -XX:MaxPermSize=512m

MaxPermSize have no use for java 8+

like image 186
Mike Avatar answered Feb 23 '23 00:02

Mike