解决Java内存泄漏的一般策略? [英] General strategy to resolve Java memory leak?

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

问题描述

我有一个我在本地运行的独立程序,它意味着是一个24/7运行的服务器类型程序。最近我发现它有内存泄漏,现在我们唯一的解决方案是每4小时重启一次。找到内存泄漏的最佳方法是什么?我们应该使用哪种工具和方法?

I have a standalone program that I run locally, it is meant to be a server type program running 24/7. Recently I found that it has a memory leak, right now our only solution is to restart it every 4 hours. What is the best way to go about finding this memory leak? Which tool and method should we use?

推荐答案

如果您使用的是Sun的Java并且至少使用Java 6更新10(即最新的),那么请尝试运行来自JDK的jvisualvm在程序运行的同一台机器上,并附加到它并启用分析。

If you are using Java from Sun and you use at least Java 6 update 10 (i.e. the newest), then try running jvisualvm from the JDK on the same machine as your program is running, and attach to it and enable profiling.

这很可能是最简单的入门方式。

This is most likely the simplest way to get started.

这篇关于解决Java内存泄漏的一般策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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