Java OutOfMemoryError时如何识别问题? [英] How to identify the issue when Java OutOfMemoryError?

查看:83
本文介绍了Java OutOfMemoryError时如何识别问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当Java OutOfMemoryErrorstackoverflow投入生产时,如何确定问题.是出于什么原因或服务器宕机的原因.

How to identify the issue when java OutOfMemoryError or stackoverflow comes in production. By which reason it is coming or why the server is down.

例如,我正在开发一个可以在生产环境和UAT上运行的应用程序.立即在生产Java OutOfMemoryErrorstackoverflow上.

For example I am developing an application which is lived on production and UAT. Instantly on production java OutOfMemoryError or stackoverflow.

那么,我们如何跟踪此问题的发生原因?有什么技术可以告诉我这是在哪个代码流中发生的吗?

Then how can we track this issue, by which reason it has happened ? Is there any technique that can tell me by which code flow this is happening ?

请解释一下.我已经多次面对这个问题.

Please explain it. I have faced this issue many times.

推荐答案

如果您在生产中遇到它,并且不能真正从堆栈跟踪或日志中推断出原因,则需要分析其中的内容.

If you face it in production and you cannot really reason about it from stacktraces or logs, you need to analyze what was in there.

让虚拟机转储到OOM

Get the VM to dump on OOM

-XX:+HeapDumpOnOutOfMemoryError 
-XX:HeapDumpPath="/tmp"

并将其用于分析.内存分析器工具( http://eclipse.org/mat/)是进行此分析的良好独立程序

And use that for analysis. The memory analyzer tool (http://eclipse.org/mat/) is a good standalone program for this analysis.

这篇关于Java OutOfMemoryError时如何识别问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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