Fix “java.lang.OutOfMemoryError: Java heap space” for Jenkins

Increasing Java heap size for Jenkins on a Debian server. 

Here’s the error we got:

SEVERE: Timer task hudson.node_monitors.AbstractNodeMonitorDescriptor$1@1d2c767 failed
java.lang.OutOfMemoryError: Java heap space

To fix this, open Jenkins configuration file /etc/default/jenkins and change the JAVA_ARGS value appropriately:

JAVA_ARGS="-Xmx2048m"

Don’t forget to restart the service:

# /etc/init.d/jenkins restart

Check logs in case of problems:

# tail -f /var/log/jenkins/jenkins.log