Android studio 将 hprof 文件转储到项目文件夹中 [英] Android studio dumping hprof file into the project folder

查看:71
本文介绍了Android studio 将 hprof 文件转储到项目文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将 gradle 版本更新到 3.3 之后(我不确定这是否会产生任何影响)但有时,我的构建需要大约 30 分钟.当构建完成或取消时,我在项目的主包中看到一个名为java_pid1160.hprof"的文件.该文件大约为 2-5~ GB.发生这种情况时,我的 CPU 工作异常,我看到风扇活动增加.我知道 hprof 文件是 java 内存转储,但由于 Android Studio 具有内存监视器并将内存转储到 hprof 文件,因此很难找到任何有用的东西.还有其他人遇到这个问题吗?

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?

推荐答案

我想说你的构建内存不足,Gradle 默认设置了 -XX:+HeapDumpOnOutOfMemoryError,所以你会得到一个内存不足时的堆转储.我想知道您是否也没有显示 OOM.

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.

您应该尝试增加授予构建的最大内存.添加 e.g.

You should try to increase the max memory that you grant to your build. Add e. g.

org.gradle.jvmargs = -Xmx2g -XX:+HeapDumpOnOutOfMemoryError

到你的项目 gradle.properties 文件(如果不存在就创建它,它必须在根项目目录中)以增加最大内存.

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.

当然也可能是您的构建脚本中存在内存泄漏,因此内存累积超过运行.如果您使用 gradlew --stop 终止 gradle 守护进程,然后此行为仅在几次构建后才会恢复,那么您可能存在内存泄漏,您应该调查并修复.如果在停止守护程序后立即失败,则您的构建可能只需要更多内存.如果问题是内存泄漏,增加最大内存只会暂时有所帮助,并且您将获得相同的行为,只是在比以前更多的构建之后.

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.

这篇关于Android studio 将 hprof 文件转储到项目文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆