Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect Out Of Memory condition?

I have an application running on Websphere Application Server 6.0 and it crashes nearly every day because of Out-Of-Memory. From verbose GC is certain there are the memory leaks(many of them)

Unfortunately the application is provided by external vendor and getting things fixed is slow & painful process. As part of the process I need to gather the logs and heapdumps each time the OOM occurs.

Now I'm looking for some way how to automate it. Fundamental problem is how to detect OOM condition. One way would be to create shell script which will periodically search for new heapdumps. This approach seems me a kinda dirty. Another approach might be to leverage the JMX somehow. But I have little or no experience in this area and don't have much idea how to do it.

Or is in WAS some kind of trigger/hooks for this? Thank you very much for every advice!

like image 353
Jaromir Hamala Avatar asked Aug 25 '09 08:08

Jaromir Hamala


1 Answers

You can pass the following arguments to the JVM on startup and a heap dump will be automatically generated on an OutOfMemoryError. The second argument lets you specify the path for the heap dump file. By using this at least you could check for the existence of a specific file to see if a heap dump has occurred.

-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=<value>
like image 200
Mark Avatar answered Oct 23 '22 18:10

Mark