3.11. Memory Considerations

Continuous Integration servers use a lot of memory. This is the nature of the beast—builds will consume memory, and multiple builds being run in parallel will consume still more memory. So you should ensure that your build server has enough RAM to cope with however many builds you intend to run simultaneously.

Jenkins naturally needs RAM to run, but if you need to support a large number of build processes, it is not enough just to give Jenkins a lot of memory. In fact Jenkins spans a new Java process each time it kicks off a build, so during a large build, the build process needs the memory, not Jenkins.

You can define build-specific memory options for your Jenkins build jobs—we will see how to do this later on in the book. However if you have a lot of builds to maintain, you might want to define the JAVA_OPTS , MAVEN_OPTS and ANT_OPTS environment variables to be used as default values for your builds. The JAVA_OPTS options will apply for the main Jenkins process, whereas the other two options will be used when Jenkins kicks off new JVM processes for Maven and Ant build jobs respectively.

Here is an example of how these variables might be configured on a Unix machine in the .profile file:

export
			JAVA_OPTS=-Djava.awt.headless=true -Xmx512m
			-DJENKINS_HOME=/data/jenkins
			export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"
			export ANT_OPTS="-Xmx512m -XX:MaxPermSize=256m"