Why does my build require more RAM than locally?

Under certain circumstances it may appear that jobs will use more RAM than expected, causing a build failure, likely resulting in the exit code 137. If your project utilizes the JVM, we have a great blog post detailing how to limit the memory usage of the JVM.

Also, check to see what and how many service containers your project is utilizing. Additional service containers such as postgres or mysql share the resources with your primary container.

Lastly, when Linux runs out of available memory, memory page files will be copied to disk in swap space. On CircleCI since we limit memory usage, once you approach this limit the build will be killed, it will not have the chance to utilize swap space. Your local build may be benefitting from the "effectively" additional RAM given by swap space.