Skip to content

Commit

Permalink
Fixed another spot where memory size was being computed. (neoforged#33)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shartte committed Nov 8, 2023
1 parent 44b82a3 commit f6f97f5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f6f97f5

Please sign in to comment.