Skip to content
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

Android builds sometimes fail with apparent OOM #418

Open
pmconne opened this issue Aug 16, 2023 · 9 comments
Open

Android builds sometimes fail with apparent OOM #418

pmconne opened this issue Aug 16, 2023 · 9 comments
Assignees

Comments

@pmconne
Copy link
Member

pmconne commented Aug 16, 2023

Execution failed for task ':app:mergeReleaseNativeDebugMetadata'.

A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeDebugMetadataTask$MergeNativeDebugMetadataWorkAction
Java heap space

@tcobbs-bentley
Copy link
Member

I just found the following:

GRADLE_OPTS
Specifies JVM arguments to use when starting the Gradle client VM. The client VM only handles command line input/output, so it is rare that one would need to change its VM options. The actual build is run by the Gradle daemon, which is not affected by this environment variable.

(See here.)

That same page includes the following:

org.gradle.jvmargs=(JVM arguments)
Specifies the JVM arguments used for the Gradle Daemon. The setting is particularly useful for configuring JVM memory settings for build performance. This does not affect the JVM settings for the Gradle client VM. The default is -Xmx512m "-XX:MaxMetaspaceSize=384m".

Between these two statements, it certainly seems that setting GRADLE_OPTS like we do in our yml script has no effect on the build memory. I know that display-test-app has the following in its gradle.properties:

org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8

The web page does in another section say that JAVA_OPTS can be used to configure the VM memory settings when the Gradle Daemon is deactivated. Since our command line does include --no-daemon, does that perhaps mean that GRADLE_OPTS will work?

@swbsi, what do you think?

@tcobbs-bentley
Copy link
Member

I also see that -Xms sets the initial pool size, while -Xmx sets the max. So if the problem is that the machine doesn't have enough virtual memory available, omitting -Xms would fix that as long as it has enough virtual memory as is actually needed.

@tcobbs-bentley
Copy link
Member

I created a PR in bsicommon to only set the max heap size, not the initial heap size (going on the assumption that the GRADLE_OPTS environment variable does in fact do what we want when using --no-daemon). I'm not sure how to test the change.

@pmconne
Copy link
Member Author

pmconne commented Sep 14, 2023

@tcobbs-bentley can you link to that PR? Are you still blocked? This is still breaking builds.

@tcobbs-bentley
Copy link
Member

@pmconne The PR is here:

https://dev.azure.com/bentleycs/iModelTechnologies/_git/bsicommon-imt/pullrequest/360429

Since we weren't sure whether we weren't allocating enough or requiring too much, that PR simply got rid of the minimum allocation. I'll submit another PR to increase the max allocation.

@tcobbs-bentley
Copy link
Member

Here is a PR to double Gradle's maximum heap size to 8GB:

https://dev.azure.com/bentleycs/iModelTechnologies/_git/bsicommon-imt/pullrequest/367245

@tcobbs-bentley
Copy link
Member

@pmconne Has it failed since my last PR above?

@pmconne
Copy link
Member Author

pmconne commented Oct 12, 2023

@pmconne Has it failed since my last PR above?

Not that I have observed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants