-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase memory used for forked compiler #1753
Increase memory used for forked compiler #1753
Conversation
When running the Gradle Daemon with a non-J21 JVM, it will fork the Java compiler into a separate process rather than running it in-process with the Daemon. However, that means the compiler process uses the default amount of memory, which is not able to compile all of NeoForge & Minecraft (as it fails with an OutOfMemoryError). Setting the memory when the compiler is forked ensures that whether the compiler runs in-process with the Daemon or as a forked process, it will always have enough memory to compile all the sources properly.
Last commit published: b961a4b5a7def793d906530bd3d256f5bcccb4ff. PR PublishingThe artifacts published by this PR:
Repository DeclarationIn order to use the artifacts published by the PR, add the following repository to your buildscript: repositories {
maven {
name 'Maven for PR #1753' // https://github.com/neoforged/NeoForge/pull/1753
url 'https://prmaven.neoforged.net/NeoForge/pr1753'
content {
includeModule('net.neoforged', 'testframework')
includeModule('net.neoforged', 'neoforge')
}
}
} MDK installationIn order to setup a MDK using the latest PR version, run the following commands in a terminal. mkdir NeoForge-pr1753
cd NeoForge-pr1753
curl -L https://prmaven.neoforged.net/NeoForge/pr1753/net/neoforged/neoforge/21.4.17-beta-pr-1753-neoforge-compiler-memory/mdk-pr1753.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip To test a production environment, you can download the installer from here. |
The Daemon should require less memory as more things are now run out of process. This also matches the max memory argument passed to the compile tasks.
🚀 This PR has been released as NeoForge version |
This PR fixes an out of memory error when compiling with a non-Java 21 JVM running the Gradle Daemon, by specifically setting the maximum memory used by the forked Java compiler process.
When running the Gradle Daemon with a non-J21 JVM, it will fork the Java compiler into a separate process rather than running it in-process with the Daemon. However, that means the compiler process uses the default amount of memory, which is not able to compile all of NeoForge & Minecraft (as it fails with an OutOfMemoryError).
Setting the memory when the compiler is forked ensures that whether the compiler runs in-process with the Daemon or as a forked process, it will always have enough memory to compile all the sources properly.
This is an alternative solution to the problem that #1692 also seeks to fix, which is more tailored to the problem by specifically addressing the root cause of the out-of-memory error.
To test, first set the Daemon to use a non-Java 21 JVM (via the
JAVA_HOME
environment variable pointed to a Java 17 JVM, for example), then run./gradlew clean
,./gradlew setup
(to prepare the workspace), then./gradlew assemble --no-build-cache --rerun-tasks
. Without this PR,:neoforge:compileJava
will fail with a "Java heap space" error; with this PR, the build will succeed.