Skip to content

Commit

Permalink
Limit memory usage in tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stuartwdouglas committed Jan 29, 2020
1 parent 4c5d8fc commit 41a238b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
18 changes: 0 additions & 18 deletions devtools/maven/src/main/java/io/quarkus/maven/RemoteDevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ protected void run(String... options) throws FileNotFoundException, MavenInvocat
// 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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public MavenProcessInvocationResult execute(List<String> goals, Map<String, Stri

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);
Expand Down

0 comments on commit 41a238b

Please sign in to comment.