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?
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
.
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+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With