Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Java memory errors?

There is a Java Struts application running on Tomcat, that have some memory errors. Sometimes it becomes slowly and hoard all of the memory of Tomcat, until it crashes.

I know how to find and repair "normal code errors", using tests, debugging, etc, but I don't know how to deal with memory errors (How can I reproduce? How can I test? What are the places of code where is more common create a memory error? ).

In one question: Where can I start? Thanks

EDIT:

A snapshot sended by the IT Department (I haven't direct access to the production application)

enter image description here

like image 514
Dr. No Avatar asked Sep 12 '26 18:09

Dr. No


2 Answers

Use one of the many "profilers". They hook into the JVM and can tell you things like how many new objects are being created per second, and what type they are etc.

Here's just one of many: http://www.ej-technologies.com/products/jprofiler/overview.html I've used this one and it's OK.

like image 191
Bohemian Avatar answered Sep 15 '26 09:09

Bohemian


http://kohlerm.blogspot.com/ It is quite good intro how to find memory leaks using eclipse memory analyzer.

If you prefer video tutorials, try youtube, although it is android specific it is very informative.

like image 35
bbaja42 Avatar answered Sep 15 '26 11:09

bbaja42



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!