From f6f97f570b3ffef421ff4738551197cc6ac8eb22 Mon Sep 17 00:00:00 2001 From: shartte Date: Wed, 8 Nov 2023 12:06:02 +0100 Subject: [PATCH] Fixed another spot where memory size was being computed. (#33) Pass heap size as megabyte, since Groovy seems to be fussy about other formats. Use integer division to prevent String.format from throwing due to invalid type conversion. --- .../groovy/net/neoforged/gradle/dsl/common/tasks/Execute.groovy | 2 +- .../gradle/neoform/runtime/tasks/RecompileSourceJar.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/tasks/Execute.groovy b/dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/tasks/Execute.groovy index 9ce03eb4c..01a62a840 100644 --- a/dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/tasks/Execute.groovy +++ b/dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/tasks/Execute.groovy @@ -130,7 +130,7 @@ interface Execute extends WithWorkspace, WithOutput, WithJavaVersion, ExecuteSpe java.getMainClass().set(mainClass) java.setStandardOutput(log_out) - java.setMaxHeapSize(String.format("%dk", Runtime.getRuntime().maxMemory() / 1000)) + java.setMaxHeapSize(String.format("%dm", Runtime.getRuntime().maxMemory().intdiv(1024 * 1024))) }).rethrowFailure().assertNormalExitValue() } } diff --git a/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/tasks/RecompileSourceJar.java b/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/tasks/RecompileSourceJar.java index 7225dd668..00f6b3c25 100644 --- a/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/tasks/RecompileSourceJar.java +++ b/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/tasks/RecompileSourceJar.java @@ -101,7 +101,7 @@ public RecompileSourceJar() { getOptions().setFork(true); getOptions().setIncremental(true); getOptions().getIncrementalAfterFailure().set(true); - getOptions().getForkOptions().setMemoryMaximumSize(String.format("%dk", java.lang.Runtime.getRuntime().maxMemory() / 1000)); + getOptions().getForkOptions().setMemoryMaximumSize(String.format("%dm", java.lang.Runtime.getRuntime().maxMemory() / (1024 * 1024))); //Leave this as an anon class, so that gradle is aware of this. Lambdas can not be used during task tree analysis. //noinspection Convert2Lambda