jamesthetester
jamesthetester

Reputation: 163

Heap size when running a batch file which runs a JVM under Jenkins

I have a Jenkins build and one step of the build is a windows batch command step that calls a bat file.

The batch file contains the following command that creates a JVM

SET JAVA_OPTS=-Xmx4g -Xms512m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m

call sbt %cmd% "run %db% %dbuser% %dbpass% %df% %dfport% %dfuser% %dfpass% %epsg% %starttime%"

If I use -Xmx4g as above the command fails in Jenkins with

Invalid maximum heap size: -Xmx4g The specified size exceeds the maximum representable size.

However if I run the same batch file outside of Jenkins on the slave machine in a command prompt I have no issues at all.

If I run the command under Jenkins with -Xmx2g then it runs out of memory as that is too small a heap size for the command but at least it runs without the Invalid maximum heap size.

How do I prevent Jenkins from constraining the JVM being ran from this build step?

I have tried the following and I have not yet found a solution that allows this build step to complete:

  1. Changing the heap size on the Jenkins Server (although its not a server side JVM with the issue)
  2. Changing the heap size allocated to the slave on which the build is running (using the JVM options on the node configuration page in the Jenkins server)

Any other suggestions?

Upvotes: 3

Views: 3431

Answers (1)

jamesthetester
jamesthetester

Reputation: 163

I was not using a 64bit version of JAVA - I changed the JAVA version on the slave to a 64 bit version, made sure that Jenkins was using this verison in both the agent and when the step that launched the JVM and now I dont have the issue I reported.

Upvotes: 1

Related Questions