After updating gradle version to 3.3 (I'm not sure if this effects anything at all) but sometimes, my build takes about 30 min. and I see a file called "java_pid1160.hprof" file in my project's main package when the build complete or cancelled. The file is around 2-5~ GB. My CPU works insanely while this happens and I see increased fan activity. I know that hprof files are the java memory dumps but since Android Studio has memory monitor and also dumping the memory to a hprof file, it is really hard to find anything useful. Anyone else having this problem?
I'd say your build went out of memory and Gradle has by default -XX:+HeapDumpOnOutOfMemoryError
set, so you get a heap dump in case of out of memory. I wonder that you don't also get the OOM displayed though.
You should try to increase the max memory that you grant to your build. Add e. g.
org.gradle.jvmargs = -Xmx2g -XX:+HeapDumpOnOutOfMemoryError
to your projects gradle.properties
file (create it if not present, it has to be in the root projects directory) to increase the max memory.
It could of course also be that you have a memory leak in your build scripts, so that the memory cumulates over runs. If you kill the gradle daemon with gradlew --stop
and then this behavior comes back only after a few builds, then you probably have a memory leak that you should investigate and fix. If it fails immediately after stopping the daemon, your build might simply need more memory. If the problem is a memory leak, increasing the max memory will only help temporarily and you will get the same behavior, just after more builds than before.
© 2022 - 2024 — McMap. All rights reserved.