学习网站,修复Java内存泄漏 [英] learning sites for fixing java memory leaks

查看:146
本文介绍了学习网站,修复Java内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

学习修复Java内存泄漏的最佳场所是什么?我一直在尝试通过NET找到好的资源,但令我失望的是,我发现正在讨论玩具示例.我还能够对小型玩具垃圾堆进行故障排除,但现实世界中的应用程序垃圾堆更具挑战性,几乎没有任何线索.

What would be the best places to learn fixing a java memory leak ? I have been trying to find good resource over the NET but to my disappointment, I find toy examples being discussed. I am also able to troubleshoot small toy dumps but the real world application dumps are more challenging and give little clue.

我尝试过Jhat,JMap,VisualVM和MAT之类的工具.

I have tried tools like Jhat, JMap, VisualVM and MAT.

什么是学习修复Java内存泄漏的最佳场所?也欢迎提出建议.

what would be the best place to learn about fixing Java memory leaks ? suggestion of a book is also welcome.

提前谢谢.

推荐答案

存在很多类型的内存泄漏,但实际上,以下策略可提供良好的效果(免责声明:我正在显示

There are many kind of memory leaks but in practice the following strategy gives good results (Disclaimer: I'm showing screen shots from JProfiler, because my company develops it):

1.检查最大的物体

最大的对象"保留了很多其他人无法保留的内存.在JProfiler中,可以在堆查询器的最大对象"视图中找到它们.缓存经常会发生这种情况.

"Biggest objects" retain a lot of memory that nobody else is holding on to. In JProfiler, they can be found in the "Biggest objects" view of the heap walker. This often happens with caches.

2.检查具有很多实例的课程

有时,引用更加复杂,最大的对象也没有提供任何线索.可以检查具有很多实例的类的传入引用.首先,查看累积的参考有助于将有效参考链与可疑参考链分开.

Sometimes, the references are more intricate and the biggest objects do not give a clue. Classes with a lot of instances can be checked for their incoming references. First, it is helpful to look at cumulated references, to separate valid reference chains from suspicious reference chains.

此外,检查实例在何处分配(而不是如何引用实例)通常可以洞悉正在发生的事情.

Also, checking where instances have been allocated (as opposed to how they are referenced) can often give an insight on what is going on.

通常,这是一个多步骤过程,选择参考链,分配位置或基于对象的内容进行选择.

Often, this is a multi-step process, selecting reference chains, allocation spots, or making selections based on the contents of objects.

3.搜索GC根目录的路径

如果仍然不能提供线索,则可以选择单个对象并显示其导致垃圾回收器根的引用链.它可以帮助很多人在尝试缩小对象范围之前先缩小范围,否则您可能会有很多候选人.

If that still does not provide a clue, you can select single objects and show their reference chains that lead to garbage collector roots. It helps a lot of you were able to narrow down an object set of suspicious objects before trying to to that, otherwise you may have a lot of candidates.

还有一个对该主题进行屏幕投射.

这篇关于学习网站,修复Java内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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