OutOfMemory Errors in Bamboo elastic agent

Still need help?

The Atlassian Community is here for you.

Ask the community

This article only applies to Atlassian's server products. Learn more about the differences between cloud and server.


Bamboo builds start failing when executed on elastic agents and the following exception is observed in the Bamboo System Error Details page (accessible through the Bamboo UI):

java.lang.OutOfMemoryError: GC overhead limit exceeded
	at java.io.UnixFileSystem.resolve(UnixFileSystem.java:108)
	at java.io.File.<init>(File.java:367)
	at org.apache.tools.ant.DirectoryScanner.scandir(DirectoryScanner.java:1256)



Diagnostic Steps

  • If the build process is running out of memory while executing a Maven or Ant task, please check the "Bamboo builds fail due to java.lang.OutOfMemoryError" knowledge base article as it describes how to workaround the problem and allocate more memory to both ANT_OPTS and MAVEN_OPTS.
  • If you are not running one of the tasks mentioned above, but the elastic agent is still running out of memory, please continue to read.


The default memory setting for the elastic agent is 256MB. It is necessary to adjust the settings to run a bigger elastic agent with sufficient memory.


For Bamboo 5.9.x and earlier versions

The elastic agents have a fixed max heap size of 256MB. It is not possible to increase the value of the default images. In this case the solution is to upgrade Bamboo to 5.10.x or later. After upgrading Bamboo it is possible to follow the next section.

For Bamboo 5.10.x and later versions

It is possible to change the heap size of the elastic agent using the Instance startup script option located at the Bamboo administration >> Overview >> Elastic Bamboo >> Image configurations page. From there edit the desired elastic image and add the following script to the Instance startup script field:


sed -i 's@.*MARKER.*@sed -i "s/-Xmx256m/-Xmx512m/" $startupScript@' /opt/bamboo-elastic-agent/bin/bamboo-elastic-agent


Option 1:
sed -i "s/-Dimagefiles/-Dbamboo.agent.syncOnly -Dimagefiles/" C:\opt\bamboo-elastic-agent\bin\bamboo-elastic-agent.bat
sed -i 's@cd %%OLD_PWD%%@sed -i \'s/-Xmx256m/-Xmx512m/\' \%%TEMP\%%\\\\bamboo-agent-bootstrap-1.bat\n\%%TEMP\%%\\\\bamboo-agent-bootstrap-1.bat ^>^>bamboo-elastic-agent.out 2^>\^&1\ncd %%OLD_PWD%%@' C:\opt\bamboo-elastic-agent\bin\bamboo-elastic-agent.bat
Option 2:

The below option will override heap sizing for any Java processes that are run after the instance starts up so may not be ideal if you're using anything Java in your builds (e.g. Gradle or Maven)

setx -m _JAVA_OPTIONS "-Xms256m -Xmx512m"

This will increase the maximum elastic agent memory to 512MB. It is possible to adjust the -Xmx setting to allocate more memory to the agent, if necessary.

Last modified on Aug 20, 2019

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.