From 41a238ba124f1e2233be0b7897a8aa6ff8974490 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 29 Jan 2020 13:52:13 +1100 Subject: [PATCH] Limit memory usage in tests Tests can have lots of processes running at once, if they all default to 75% of physical memory we can run out, as processes can continue to allocate instead of running GC --- .../java/io/quarkus/maven/RemoteDevMojo.java | 18 ------------------ .../maven/it/RunAndCheckMojoTestBase.java | 6 ++++++ .../maven/it/verifier/RunningInvoker.java | 6 ++++++ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/devtools/maven/src/main/java/io/quarkus/maven/RemoteDevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/RemoteDevMojo.java index 628ad34a9..9dbc2c98e 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/RemoteDevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/RemoteDevMojo.java @@ -18,7 +18,6 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; -import org.apache.maven.toolchain.ToolchainManager; import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; import org.eclipse.microprofile.config.spi.ConfigProviderResolver; @@ -49,29 +48,12 @@ public class RemoteDevMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.sourceDirectory}") private File sourceDir; - @Parameter(defaultValue = "${jvm.args}") - private String jvmArgs; - @Parameter(defaultValue = "${session}") private MavenSession session; - @Parameter(defaultValue = "TRUE") - private boolean deleteDevJar; - @Component private MavenVersionEnforcer mavenVersionEnforcer; - @Component - private ToolchainManager toolchainManager; - - public ToolchainManager getToolchainManager() { - return toolchainManager; - } - - public MavenSession getSession() { - return session; - } - @Override public void execute() throws MojoFailureException, MojoExecutionException { mavenVersionEnforcer.ensureMavenVersion(getLog(), session); diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckMojoTestBase.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckMojoTestBase.java index 1b1340aa4..ff24b3153 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckMojoTestBase.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckMojoTestBase.java @@ -46,6 +46,12 @@ public class RunAndCheckMojoTestBase extends MojoTestBase { // if no explicit debug options have been specified, let's just disable debugging args.add("-Ddebug=false"); } + + //we need to limit the memory consumption, as we can have a lot of these processes + //running at once, if they add default to 75% of total mem we can easily run out + //of physical memory as they will consume way more than what they need instead of + //just running GC + args.add("-Djvm.args=-Xmx128m"); running.execute(args, Collections.emptyMap()); } diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java index 57ff6b96a..a7082a219 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java @@ -118,6 +118,12 @@ public class RunningInvoker extends MavenProcessInvoker { if (System.getProperty("mavenOpts") != null) { request.setMavenOpts(System.getProperty("mavenOpts")); + } else { + //we need to limit the memory consumption, as we can have a lot of these processes + //running at once, if they add default to 75% of total mem we can easily run out + //of physical memory as they will consume way more than what they need instead of + //just running GC + request.setMavenOpts("-Xmx128m"); } request.setShellEnvironmentInherited(true);