assembleDebug runs out of memory when rebuilding all examples
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #28 来自 @afarber —— 已合并
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 领域
- build-system
调研方向
The fix is configuration, so start in gradle.properties (the org.gradle.jvmargs=-Xmx4096m heap and where worker limits would go) and check settings.gradle.kts. The failing task is mergeExtDexDebug in the example modules, such as examples:Example04Polylines. Reproduce with ./gradlew --stop then ./gradlew assembleDebug --rerun-tasks. Done means that command succeeds without --max-workers. Confirm with the maintainer which of the two proposed fixes to take, since raising the heap and capping workers trade off differently.
由索引模型根据 Issue 内容生成。
描述
A full rebuild of the example apps fails with OutOfMemoryError: Java heap space in the Gradle daemon on machines with many CPU cores.
Steps to reproduce
./gradlew --stop
./gradlew assembleDebug --rerun-tasks
On a 14-core Mac this fails after about 15 seconds, usually in mergeExtDexDebug of one or more examples:
> Task :examples:Example04Polylines:mergeExtDexDebug FAILED
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Caused by: java.lang.OutOfMemoryError: Java heap space
After the failure the daemon can be left in a broken state ("Cannot lock file hash cache ... already been locked by this process"), so ./gradlew --stop is needed before the next build.
The same failure also happens without --rerun-tasks whenever all examples need to be rebuilt, for example after a change in the library or in settings.gradle.kts. Incremental builds are not affected.
Cause
All 12 example apps run dex merging in parallel inside the Gradle daemon. The number of parallel workers defaults to the number of CPU cores, but the daemon heap is limited to 4 GB (org.gradle.jvmargs=-Xmx4096m in gradle.properties). CI is not affected because its runners have fewer cores.
Limiting the workers avoids the problem:
./gradlew --stop
./gradlew assembleDebug --rerun-tasks --max-workers=4 # BUILD SUCCESSFUL
Possible fixes
- Increase the daemon heap in
gradle.properties, for example-Xmx6g - Or limit parallelism with
org.gradle.workers.maxingradle.properties
- 主要语言
- Kotlin
- 星标
- 4
- 派生
- 1
- 平均合并
- 1 小时 55 分钟
- 30 天内合并 PR
- 29
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
-
bug core p3
难度 2/5 1-3 小时 新手友好度 70/100
RunanywhereAI/runanywhere-sdks#1083 ·
维护者通常 5 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 1/5 1 小时以内 新手友好度 88/100
SLNE-Development/surf-chat#134 ·