8347126: gc/stress/TestStressG1Uncommit.java gets OOM-killed

Reviewed-by: tschatzl, gli
This commit is contained in:
Aleksey Shipilev 2025-01-09 09:49:14 +00:00
parent 82e16ba248
commit dff5719e6f

View File

@ -57,6 +57,7 @@ public class TestStressG1Uncommit {
Collections.addAll(options,
"-Xlog:gc,gc+heap+region=debug",
"-XX:+UseG1GC",
"-Xmx1g",
StressUncommit.class.getName()
);
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(options);
@ -79,9 +80,9 @@ class StressUncommit {
// Leave 20% head room to try to avoid Full GCs.
long allocationSize = (long) (Runtime.getRuntime().maxMemory() * 0.8);
// Figure out suitable number of workers (~1 per gig).
int gigsOfAllocation = (int) Math.ceil((double) allocationSize / G);
int numWorkers = Math.min(gigsOfAllocation, Runtime.getRuntime().availableProcessors());
// Figure out suitable number of workers (~1 per 100M).
int allocationChunks = (int) Math.ceil((double) allocationSize / (100 * M));
int numWorkers = Math.min(allocationChunks, Runtime.getRuntime().availableProcessors());
long workerAllocation = allocationSize / numWorkers;
log("Using " + numWorkers + " workers, each allocating: ~" + (workerAllocation / M) + "M");