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

查看:379
本文介绍了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天全站免登陆