mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-24 14:34:15 +08:00
Fix the problem of adding redundant G1 parameters (#2092)
This commit is contained in:
parent
a8c1e8d2cb
commit
bffbfd7af9
@ -180,22 +180,14 @@ public class DefaultLauncher extends Launcher {
|
||||
res.addDefault("-Duser.home=", options.getGameDir().getParent());
|
||||
|
||||
// Using G1GC with its settings by default
|
||||
if (options.getJava().getParsedVersion() >= JavaVersion.JAVA_8) {
|
||||
boolean addG1Args = true;
|
||||
for (String javaArg : options.getJavaArguments()) {
|
||||
if ("-XX:-UseG1GC".equals(javaArg) || (javaArg.startsWith("-XX:+Use") && javaArg.endsWith("GC"))) {
|
||||
addG1Args = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addG1Args) {
|
||||
res.addUnstableDefault("UnlockExperimentalVMOptions", true);
|
||||
res.addUnstableDefault("UseG1GC", true);
|
||||
res.addUnstableDefault("G1NewSizePercent", "20");
|
||||
res.addUnstableDefault("G1ReservePercent", "20");
|
||||
res.addUnstableDefault("MaxGCPauseMillis", "50");
|
||||
res.addUnstableDefault("G1HeapRegionSize", "32m");
|
||||
}
|
||||
if (options.getJava().getParsedVersion() >= JavaVersion.JAVA_8
|
||||
&& res.noneMatch(arg -> "-XX:-UseG1GC".equals(arg) || (arg.startsWith("-XX:+Use") && arg.endsWith("GC")))) {
|
||||
res.addUnstableDefault("UnlockExperimentalVMOptions", true);
|
||||
res.addUnstableDefault("UseG1GC", true);
|
||||
res.addUnstableDefault("G1NewSizePercent", "20");
|
||||
res.addUnstableDefault("G1ReservePercent", "20");
|
||||
res.addUnstableDefault("MaxGCPauseMillis", "50");
|
||||
res.addUnstableDefault("G1HeapRegionSize", "32m");
|
||||
}
|
||||
|
||||
res.addUnstableDefault("UseAdaptiveSizePolicy", false);
|
||||
|
@ -211,6 +211,10 @@ public final class CommandBuilder {
|
||||
return raw.removeIf(i -> pred.test(i.arg));
|
||||
}
|
||||
|
||||
public boolean noneMatch(Predicate<String> predicate) {
|
||||
return raw.stream().noneMatch(it -> predicate.test(it.arg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return raw.stream().map(i -> i.parse ? parse(i.arg) : i.arg).collect(Collectors.joining(" "));
|
||||
|
Loading…
Reference in New Issue
Block a user