admin管理员组

文章数量:1387404

I'm facing an issue with Gradle builds failing on our Azure Pipelines CI/CD setup due to insufficient memory. The VM we use has 16GB of RAM, but at certain points during the build, it runs out of resources and crashes.

Is it normal for an Android build to require more than 16GB of RAM? Are there any optimizations I can make on my end as an Android developer to reduce memory usage?

In case it helps, in my application, I make use of dagger hilt and it is single module. Any insights or suggestions would be greatly appreciated!

I'm facing an issue with Gradle builds failing on our Azure Pipelines CI/CD setup due to insufficient memory. The VM we use has 16GB of RAM, but at certain points during the build, it runs out of resources and crashes.

Is it normal for an Android build to require more than 16GB of RAM? Are there any optimizations I can make on my end as an Android developer to reduce memory usage?

In case it helps, in my application, I make use of dagger hilt and it is single module. Any insights or suggestions would be greatly appreciated!

Share Improve this question asked Mar 17 at 9:36 Nontas PapadopoulosNontas Papadopoulos 211 silver badge4 bronze badges 1
  • Hi @NontasPapadopoulos, Good day. If the answer below may help resolve the issue in this post, please consider this, which may help other community members with similar concerns. Thx for the sharing. – Aguy Commented Mar 20 at 2:43
Add a comment  | 

1 Answer 1

Reset to default 1

Android builds can be memory hogs, especially with Dagger Hilt, Kotlin, and large projects. But 16GB should usually be enough if managed properly.

You can set these settings which can help you prevent OOM (basically limit gradle usage)

.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
.gradle.parallel=true
.gradle.daemon=true
.gradle.configureondemand=true
.gradle.caching=true

Usually Azure VMS also have limited cores, you can also limit the thread spawns

.gradle.workers.max=2

Also I would recommend you to move to a multi module approach, which only builds whats needed, inspite of whole app module.

本文标签: androidGradle Build Failing on Azure Pipelines Due to RAM LimitationsStack Overflow