简体   繁体   中英

Jenkins Server cannot compile because no heap space could reserved

I have a big problem with my jenkins server: I Cant build a maven project, because the java vm cannot start:

Checkout:workspace / /var/lib/jenkins/jobs/SchwarzGoldTool/workspace - hudson.remoting.LocalChannel@b7193fc
Using strategy: Default
Last Built Revision: Revision c2d18fd7a5d7f112163e9440a8e7256a44e32f46 (origin/HEAD, origin/master)
Checkout:workspace / /var/lib/jenkins/jobs/SchwarzGoldTool/workspace - hudson.remoting.LocalChannel@b7193fc
Fetching changes from 1 remote Git repository
Fetching upstream changes from git://.../tsc.git
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 2b4654302e8222509db5808c9071ec95daf0b495 (origin/HEAD, origin/master)
Checking out Revision 2b4654302e8222509db5808c9071ec95daf0b495 (origin/HEAD, origin/master)
Warning : There are multiple branch changesets here
Parsing POMs
Modules changed, recalculating dependency graph
[SchwarzGoldTool] $ java -Xmx512M -Xms512M -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.2.jar:/var/lib/jenkins/tools/Maven_3.0.3/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /var/lib/jenkins/tools/Maven_3.0.3 /var/run/jenkins/war/WEB-INF/lib/remoting-2.11.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.2.jar 58359
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
ERROR: Failed to launch Maven. Exit code = 1
Finished: FAILURE

I tried to add -Xmx and -Xms to the VM (as you can see) but that doesnt work either... someone has a idea whats going on there?

The problem is caused by Jenkins failed to reserve enough heap space to kick off a maven build. From what you said, it seems like there are few things which share your VM limit, (I included the estimation of the memory required to run each process)

  • The VM's OS (~200~300mb)
  • Jenkins (~min 256mb)
  • Webcontainers (~256~512mb)
  • etc. (~100mb)

My memory estimation is rather conservative, but still, it's easily adds up to over 1gb, which leave the available heap for Jenkins to reserve to less than the Xms (512m), hence, failed to kick off a build

Ideally you should increase the softlimit on your VM to a higher value. If that is not feasible, my advice will be to reduce the memory management of the build by change the job configuration in Jenkins to something like this, (Xmx512m, Xms128m) so that Jenkins can kick off a build with only 128m free heap. But this setting may cause out of memory error in the later stage, when the build required a heap which is below Xmx but above the available heap.

Alternatively, you can memory manage other processes I mentioned above or you can setup some configure the virtual memory on your VM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM