如何使用visualvm查找内存泄漏 [英] How to find memory leaks using visualvm

查看:234
本文介绍了如何使用visualvm查找内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑我们的ActiveMQ连接桥有一个主要的内存泄漏 - 我们看到典型的内存泄漏模式(应用程序加载正常,如果长时间运行或在短时间内一次又一次地重新启动,则会减慢速度时间)。我找到了查找Java内存泄漏的现代最佳实践,许多开发人员似乎放弃了传统工具,如jhat / jmap,而不是新的(呃) jvisualvm 。 / p>

启动此工具(并花了几个小时阅读其教程)后,我可以为CPU和内存拍摄分析器快照。



我只是在这一点上陷入困​​境 - 如何分析这些快照来识别泄漏?关于如何使用jvisualvm生成快照的文档很多,但关于如何真正理解它们的文档很少。



提前致谢。

解决方案

使用visualvm分析内存泄漏并不容易。它有一个名为'sampler'的工具/插件。这可以用于采样内存或CPU。您可以定期拍摄快照并查找可能的泄漏。以下是有关如何使用它的一些细节 - 从快速搜索中获取



更有效的方法是获得堆转储(例如,当应用程序减速时或 OOM发生了)。 VisualVM帮助您获取heapdump(在监视器选项卡上使用堆转储



此文件可以通过< a href =http://wiki.eclipse.org/index.php/MemoryAnalyzer#Finding_Memory_Leaks =noreferrer> MAT - 一些细节在如何分析.hprof文件? http://memoryanalyzer.blogspot.in/


I suspect we have a major memory leak in our ActiveMQ connection bridge - we're seeing typical memory leak patterns (app loads fine, slows down if it runs for prolonged periods of time or is restarted over and over again over short periods of time). I looked up modern best practices for finding Java memory leaks and a lot of developers seem to be abandoning traditional tools like jhat/jmap in lieu of the new(er) jvisualvm.

Upon launching this tool (and spending a few hours reading over its tutorial) I am able to take profiler snapshots for both CPU and memory.

I'm just sort of stuck at this point - how do I analyze these snapshots to identify the leak? There's a plethora of documentation out there as to how to use jvisualvm to produce snapshots, but very little documentation as to how to actually make sense of them.

Thanks in advance.

解决方案

Analysing memory leak using visualvm is not that easy. It has a tool/plugin called 'sampler'. This can be used to sample memory or cpu. You can take snapshot at regular interval and look for possible leaks. Here is some details on how to use it- Obtained from quick search

More effective way will be to get a heap dump (say when the application has slowed down or when OOM happens). VisualVM help you to take heapdump (using Heap Dump on Monitor tab)

This file can be analysed by MAT- Some details are here at How do I analyze a .hprof file? and http://memoryanalyzer.blogspot.in/

这篇关于如何使用visualvm查找内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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