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?
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.
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
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+
When running Maven via Jenkins I got this error:
ERROR: Maven JVM terminated unexpectedly with exit code 137
I accidently put an "and" in the MAVEN_OPTS parameter:
-Xmx1024m and -Xms1024m
Then, I got this error:
Error: Could not find or load main class and
ERROR: Failed to launch Maven. Exit code - 1
After, removing the 'and', I reran Jenkins and received this error:
java.lang.OutOfMemoryError: Java heap space
Finally, I increased the memory using Global MAVEN_OPTS:
-Xmx4096m -Xms4096m
This fixed the problem. So, this seems to be related to memory. However, it could be a machine/VM related issue (as #boskoop stated above) or a container issue (if JVM is run through Jenkins/Docker/etc).
I ran into the same error code. This error code does indeed seem related to JVM resource constraints in the Jenkins environment. I would suggest re-running the build a second time after the error occurs to see if you can get additional/different output, though this will certainly depend on which part of the build caused the resource issues (in my cause it was a Maven downloads).
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000fb7cb000, 7331840, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 7331840 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /vagrant/args4java/hs_err_pid10470.log
ERROR: Maven JVM terminated unexpectedly with exit code 1
Finished: FAILURE
Related
I am new to ElasticSearch, but already in trouble.
My configuration:
Windows 7 Enterprise 64 bits
8 Gb RAM
I am unsuccessful at simply starting the instance, using elasticsearch.bat :
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Adter exploring SO forums as well as ElasticSearch support pages, here is what I tried:
setting min and/or max heap memory (using SET ES_MAX_MEM and SET ES_MIN_MEM on the command line before calling elasticsearch.bat) to various values, from 256m/512m to 256m/3g ==> no change in error message
setting heap size (using SET ES_HEAP_SIZE on the command line before calling elasticsearch.bat) to various values, from 256m to 3g ==> no change in error message
uninstalled my Java 7 environment and fresh installed Java 8 64 bits (checked through java -version on the command line) ==> no change in error message
Surprisingly enough, I can't seem to find any logging information (no 'logs' directory present in %ES_HOME% where the elasticsearch.org documentation states it should be...)
Would anyone point me to the right direction to get the thing up and running?
Thanks a lot
Finally got it sorted out by forcing JAVA_HOME to point to my fresh Java 8 install (seems 'java' command resorted to old java install although the Java 8 installer claimed it had cleaned previous installs).
Thanks a lot
I am getting below error on starting SonarQube:
Error occured during initialixation of VM: Could not reserve enough space for memory heap
Also modified wrapper.conf underSonarQube conf folder, but didn't work.
Also changed java version: Java 8 to Java 7, didn't work
You do not enough available memory to run SonarQube. Try closing some applications.
If this is not enough check whether SonarQube's startup script specifies the amount of memory required, e.g. with options like -Xms=??? -Xmx=???. These indicate roughly the minimum and maximum amount of memory Java will acquire. Note the actual values and check with the task manager if you have enough memory available.
Issue was with version mismatch of plugins installed in sonarqube. I deleted jars for all plugins except java. This solved the issue.
I figured it out from sonar.log
Thanks
Its due to lack of memory. if you are trying that with ANT try the following
set ANT_OPTS=-XX:MaxPermSize=128m
I'm trying to build a GWT project, using Maven. When gwt-maven-plugin tries to compile the code, it throws an error:
[ERROR] Error: Could not create the Java Virtual Machine.
[INFO] Could not reserve enough space for object heap
I tried mvn -Dgwt.extraJvmArgs=-Xmx1280m clean install, it didn't help.
An obvious solution is usually to set MAVEN_OPTS system variable. So, I've added MAVEN_OPTS with value -XX:MaxPermSize=512m -Xmx1280m. If I run echo %MAVEN_OPTS%, I see -XX:MaxPermSize=512m -Xmx1280m.
Now, if I try to run mvn clean install, I get:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
That's strange, because task manager says, that I have 5.9 Gb of available RAM. Why can this error be thrown? Why cannot it reserve the desired space? I'm using 32-bit JVM and Windows 8.
UPDATE: 64-bit JVM helped. I didn't think, that -XX:MaxPermSize=512m -Xmx1280m is too much for 32-bit JVM.
You need to pass the configuration to the gwt-maven-plugin via
mvn -Dgwt.extraJvmArgs=-Xmx1280m clean install
see also http://mojo.codehaus.org/gwt-maven-plugin/compile-mojo.html
You could also try to reduce the amount of memory:
Could not reserve enough space for object heap
This sounds like the JVM can't reserve the desired space. Try -Xmx1024m or -Xmx768m.
If this also doesn't work, you could try to use a 64 bit JVM to compile the code.
Was trying to install a module using maven in IntelliJ IDEA. It threw the following error on doing so
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
My questions are:
Is this due to the VM size settings in idea/bin/vmoptions file? Will increasing it make any difference?
If so, how do I do it? Since I don't have the necessary privileges to edit the file, is there an other option to change it from IntelliJ rather than editing the file?
If not possible will it be really worth requesting for admin priv for changing it?
Edit: Current vmoptions file contents (using Intellij IDEA 8.1.4 )
-Xms32m
-Xmx256m
-XX:MaxPermSize=150m
-ea
There are two sides to this.
If you're using a 32-bit JVM and have 4GB or more memory, then you may be running into an issue with non-contiguous Java memory. The solution there would be to switch over to a 64-bit JVM.
If you're using a 64-bit JVM already, then increase the amount of memory you use when running your application. Here are some numbers:
-Xms128m
-Xmx512m
-XX:MaxPermSize=300m
-ea
There are two files in the Intellij installation directory idea.exe.vmoptions and idea64.exe.vmoptions.
I was changing the wrong file for a while to increase the memory and could not get it to work.
Open the appropriate file and increase the memory as mentioned in the previous answer to solve this problem.
facing some problem with java virtual machine initialization. when i am using root account i can properly work with java. but when i am a user account it returns following errors
user#host# $JAVA_HOME/bin/java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
It does not seems like a memory issue as the same command works with root account. Available memory (free -m) is more than 1200MB
Also i have tried increasing the JVM memory limits
Just be careful. You will get this message if you try to enter a command that doesn't exist, e.g.:
/usr/bin/java -v
I had this issue today, and for me the problem was that I had allocated too much memory:
-Xmx1024M -XX:MaxPermSize=1024m
Once I reduced the PermGen space, everything worked fine:
-Xmx1024M -XX:MaxPermSize=512m
I know that doesn't look like much of a difference, but my machine only has 4GB of RAM, and apparently that was the straw that broke the camel's back. The Java VM was failing immediately upon every action because it was failing to allocate the memory.
Set the JVM memory:
export _JAVA_OPTIONS=-Xmx512M
The problem got resolved when I edited the file /etc/bashrc with same contents as in /etc/profiles and in /etc/profiles.d/limits.sh and did a re-login.
Make sure the physical available memory is more then VM defined min/max memory.