assembleDebug runs out of memory when rebuilding all examples
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #28 de @afarber — fusionado
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- build-system
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Kotlin
- Estrellas
- 4
- Forks
- 1
- Merge medio
- 1 h 1 min
- PR fusionados (30 d)
- 10
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Issues similares
-
bug need-device
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
ramesh130/superplayer#495 ·
Los mantenedores suelen responder en 1 día
-
Remove song from playlistAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
maxrave-dev/SimpMusic#2649 ·
Los mantenedores suelen responder en 2 días
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
PimpinPumpkin/Vela#778 ·
Los mantenedores suelen responder en 1 día
-
M1 manhwa listAbiertoBug Domain changed
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
keiyoushi/extensions-source#19882 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 3 días