Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Maven Build 137 Error

I have a Maven project, which builds 6 separate Maven projects in Jenkins. The problem I face is that over the time the project build fails giving the 137 error code:

ERROR: Maven JVM terminated unexpectedly with exit code 137

The project could be built successfully using same Maven goals in the console, but in Jenkins it fails. By restarting Jenkins the problem can be resolved.

I have some static array lists. These lists are used for some test cases. Could this be a memory leak?

like image 412
user2822319 Avatar asked Jul 28 '14 06:07

user2822319


People also ask

Does Jenkins support Maven for building?

Jenkins can use Maven as its build tool.

How will you configure Maven in Jenkins?

In the Jenkins dashboard (Home screen), click Manage Jenkins from the left-hand side menu. Then, click on 'Configure System' from the right hand side. In the Configure system screen, scroll down till you see the Maven section and then click on the 'Add Maven' button. Uncheck the 'Install automatically' option.


3 Answers

I was running into the same behavior on our build server. The error is IMHO not associated with the maven memory settings (i.e. MAVEN_OPTS) but rather with the memory of the underlying (Linux) machine itself (which Jenkins runs on).

The (rejected) Jenkins issue https://jenkins-ci.org/issue/12035 gives more detail on this matter:

For reference the status code 137 (128 + 9) typically means (can differ between flavours of unix). That the process was terminated by receipt of a signal. In this case signal 9 which is SIGKILL and unblockable kill.

If this is the case the underlying machine/OS needs more virtual memory. This can be added by either adding physical memory or swap space as appropriate.

You should try to increase the virtual memory of your machine.

Note:
This also explains why a Jenkins restart (temporarily) fixes the issue.

like image 70
boskoop Avatar answered Oct 22 '22 00:10

boskoop


I believe you should increase the values of the memory settings - in MAVEN_OPTS on the Jenkins machine, e.g.

MAVEN_OPTS=-Xmx1.5G -XX:MaxPermSize=0.7G 
like image 8
Mateva Avatar answered Oct 22 '22 02:10

Mateva


If you machine has at least 2 processors and 4GB memory, your JVM will not only grab 1GB at startup but will turn -server mode, meaning memory will be retained for performance sake (source). If you have few JVMs running at the same time (several application components, maven builds etc.) you can easily get into low memory. And one of you JVM may be killed by Linux OOM Killer because you are low on resources on the machine.

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 3
Mike Avatar answered Oct 22 '22 00:10

Mike