Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a java heap OutOfMemory error in a production environment?

Tags:

java

profiling

Our web app is running in tomcat7 and we're using java 1.7.0_55....In the past when we've had problems we've been able to debug in our development environments using Eclipse and a profiler (the name escapes me at the moment).

Now we're getting an OutOfMemory exception in our production environment. I'm quite leery of running a profiler in a production environment so my question is...Is there any way to debug this problem in the production environment without using a profiler or is there something that is light-weight enough that I could run it in production?

like image 761
kasdega Avatar asked Nov 01 '22 04:11

kasdega


2 Answers

Just take a heap dump of production server & analyse it with Eclipse Memory analysis tool. You can copy the heapdump to your local. Eclipse Memory Analyzer is the best tool for this job. However, trying to get the UI to run remotely is very painful. Launching Eclipse and updating the UI is an extra load on the JVM that is already busy analyzing a 30G heap dump. Fortunately, there is a script that comes with MAT to parse the the heap dump and generate HTML reports without ever having to launch Eclipse!

Check this out.

like image 184
underdog Avatar answered Nov 09 '22 09:11

underdog


If you want to profile your application on production you can use jConsole for real histogram from your production system. If you can pay, you should try jProfiler (https://www.ej-technologies.com/products/jprofiler/overview.html). Its really helpful for dumping data of JVM on production enviroment.

like image 39
codeaholicguy Avatar answered Nov 09 '22 11:11

codeaholicguy