Skip to content

Commit a7e4327

Browse files
committed
Run Surefire tests in a forked JVM so -Xmx2g actually applies
The default and coverage profiles set forkCount=0, which makes Surefire run tests inside Maven's own JVM. argLine — including the -Xmx2g heap limit — is only applied to a forked test JVM, so under forkCount=0 it was silently ignored and tests used whatever heap MAVEN_OPTS gave the build process. This worked locally (developer Macs have plenty of headroom) but caused recurring OutOfMemoryError on the GitHub-hosted macOS runner, which has tighter RAM than the Linux/Windows runners. Switch both profiles to forkCount=1 + reuseForks=true so the heap limit is honored on every platform, with negligible (~1–2 s) fork startup overhead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Increase Maven Surefire heap size to 4GB for testing
1 parent f47a04d commit a7e4327

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,18 @@
257257
<build>
258258
<plugins>
259259
<!-- Configure the maven-surefire-plugin to use a heap size of 2gb while running tests. -->
260+
<!-- forkCount=1 with reuseForks=true runs tests in a single forked JVM; -->
261+
<!-- without this, argLine (and therefore -Xmx) would be ignored because -->
262+
<!-- tests would share Maven's own JVM (whose heap defaults are smaller and -->
263+
<!-- vary per CI runner — macOS GitHub runners OOM under that setup). -->
260264
<!-- Assertions are disabled via -da flag to avoid a bug in bigdataviewer-core:, see https://github.com/bigdataviewer/bigdataviewer-core/pull/217. -->
261265
<plugin>
262266
<groupId>org.apache.maven.plugins</groupId>
263267
<artifactId>maven-surefire-plugin</artifactId>
264268
<version>3.1.0</version>
265269
<configuration>
266-
<forkCount>0</forkCount>
270+
<forkCount>1</forkCount>
271+
<reuseForks>true</reuseForks>
267272
<argLine>-Xmx2g -da -Dimagej.legacy.disable=true</argLine>
268273
</configuration>
269274
</plugin>
@@ -275,12 +280,17 @@
275280
<build>
276281
<plugins>
277282
<!-- Configure the maven-surefire-plugin to use a heap size of 2gb while running tests for jacoco coverage analysis. -->
283+
<!-- forkCount=1 with reuseForks=true keeps the jacoco agent argLine effective -->
284+
<!-- against a forked test JVM rather than Maven's own (see comment in the -->
285+
<!-- default profile above). -->
278286
<!-- Assertions are disabled via -da flag to avoid a bug in bigdataviewer-core:, see https://github.com/bigdataviewer/bigdataviewer-core/pull/217. -->
279287
<plugin>
280288
<groupId>org.apache.maven.plugins</groupId>
281289
<artifactId>maven-surefire-plugin</artifactId>
282290
<version>3.1.0</version>
283291
<configuration>
292+
<forkCount>1</forkCount>
293+
<reuseForks>true</reuseForks>
284294
<argLine>@{argLine} -Xmx2g -da</argLine>
285295
</configuration>
286296
</plugin>

0 commit comments

Comments
 (0)