Add javaHeapSpaceHandler to handle Gradle build failures due to Java …#185127
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new error handler, javaHeapSpaceHandler, to detect Java heap space exhaustion during Gradle builds and suggest increasing memory limits in gradle.properties. Feedback suggests refining the user instructions to avoid overwriting existing JVM arguments when updating the configuration file.
| 'If org.gradle.jvmargs is already set, append these flags to the existing value ' | ||
| '(keep your other JVM arguments, such as file encoding):\n' | ||
| '-Xmx4G -XX:MaxMetaspaceSize=2G\n' | ||
| 'If org.gradle.jvmargs is not set, add a line such as:\n' | ||
| 'org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G', | ||
| ); | ||
| globals.printBox( | ||
| '${globals.logger.terminal.warningMark} The Gradle build ran out of Java heap space.\n' | ||
| '$textInBold\n\n' | ||
| 'If this error continues, increase the -Xmx and -XX:MaxMetaspaceSize values based on your machine resources.', |
There was a problem hiding this comment.
Since we don't know how much memory will be needed, instead of giving values just point them at the documentation: https://docs.gradle.org/current/userguide/config_gradle.html#sec:configuring_jvm_memory
Suggestion: "Adjust the maximum java heap allocation according to the documentation: https://docs.gradle.org/current/userguide/config_gradle.html#sec:configuring_jvm_memory"
There was a problem hiding this comment.
Updated. Thank you.
There was a problem hiding this comment.
I have updated as per your suggestions. could you please check it ? @mboetger?
691d5dc to
5ec7a1c
Compare
…r in flutter_tools
…r in flutter_tools
reidbaker
left a comment
There was a problem hiding this comment.
I am not convinced that increasing the heap size will actually fix the issue for all users but I dont have better advice and we are linking to gradle docs which I do like.
|
As this branch is not updated, I'm updating this. |
5ec7a1c to
3614a46
Compare
|
I've run |
|
Analyze issues. See failed test To fix, run |
|
autosubmit label was removed for flutter/flutter/185127, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
|
autosubmit label was removed for flutter/flutter/185127, because - The status or check suite ci.yaml validation has failed. Please fix the issues identified (or deflake) before re-applying this label. |
6231238 to
3d30b86
Compare
|
@gmackall, can you add CI/CD again? |

Adds a new Gradle error handler in
flutter_toolsfor Java heap space failures (java.lang.OutOfMemoryError: Java heap space).When detected, Flutter now shows a clear
Flutter Fixmessage with actionable guidance to increaseorg.gradle.jvmargsinandroid/gradle.properties, instead of only surfacing raw Gradle output.Fixes #163801.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.