如何分析.hprof文件中的堆数据并使用它减少内存泄漏? [英] How to analyze heap data from .hprof file and use it to reduce memory leaks?

查看:821
本文介绍了如何分析.hprof文件中的堆数据并使用它减少内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我在运行应用程序时遇到java.lang.OutOfMemoryError异常.

在这样的一个实例中,我能够使用jvisualvm进行堆转储.

我能够使用NetBeans 8.1 IDE打开从堆转储获得的.hprof堆转储文件,但是我不知道如何分析数据转储.从应用程序的角度来看,我想知道如何读取转储文件并采取纠正措施以减少内存不足异常.

解决方案

有很多方法可以找到导致内存泄漏的根本原因,例如使用诸如 MAT ,您可以在此视频中看到,您将能够分析堆转储并提出导致内存泄漏的潜在原因. (您可以找到有关可疑报告的更多信息Java Flight Recorder ="noreferrer">此方法.或使用此视频中所述的方法使用 JVisualVM . /p>

In recent times, I have encountered java.lang.OutOfMemoryError exception while running an application.

During one such instance, I was able to get the heap dump using jvisualvm.

I am able to open the .hprof heap dump file obtained from the heap dump using NetBeans 8.1 IDE but I am not aware of how to analyze the data dump. I'd like to know how to read the dump file and take corrective actions to reduce the out of memory exception from an application perspective.

解决方案

There are many ways to find the root cause of a memory leak, like using a profiler such as JProfiler and simply applying what is described in this great video. You could also have a look to Eclipse Memory Analyzer also know as MAT that will be able to analyze your heap dump and propose potential causes of your memory leak as you can see in this video (you can find more information about the Suspect Report here). Another way could be to use Java Flight Recorder by applying this approach. Or using JVisualVM using the approach described in this video.

这篇关于如何分析.hprof文件中的堆数据并使用它减少内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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