SBT out of memory with subprojects
<p>We're using SBT 0.13 and a Java 8 JVM on CircleCI to build a Play application with several subprojects. We were occasionally getting out of memory issues on CircleCI, where it aborted our build because it exceeded 4 GB of memory usage.</p>

<p>Yesterday, I added a new subproject to our build, and almost all builds fail now on the out of memory issue. It looks like adding subprojects also adds to the amount of memory used for our build.</p>

<p>I've tried several things to reduce our memory load:</p>

<ul>
<li>Add <code>_JAVA_OPTIONS: "-Xms512m -Xmx2048"</code> to <code>circle.yml</code> as described on <a href="https://circleci.com/docs/oom/" rel="nofollow noreferrer">CircleCI's documentation pages</a>. (I noticed from the log that the JVM does pick up on this setting.)</li>
<li>Add a <code>-mem</code> parameter to the SBT call.</li>
<li>Add <code>concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)</code> to the top of the SBT file, to make sure that at least the memory isn't used all at once.</li>
</ul>

<p>All of these measures seemed to have helped, but I haven't found the definitive solution to this problem yet.</p>

<p>What else can I do to keep SBT's memory usage under control?</p>

<p><strong>EDIT</strong>: Our project has 5 subprojects, with about 14000 lines of Scala code (and also, 21000 lines of Java code that we 'inherited'). The out-of-memory usually (but not always) occurs while executing static analysis using FindBugs: we use that in conjunction with the FindSecurityBugs plugin to find security issues.</p>