Wednesday, April 7, 2010

Java - Heap Dump

Memory is always an issue for software. Whenever it occurs, you will always find it difficult to track them down. If you are using Java6, you can use the following to as help

1. Include JVM options -XX:+HeapDumpOnOutOfMemoryError

This will create a heap dump whenever a OutOfMemoryException occurs. It will output a .hprof file at your root folder

Then, use jhat .hprof to analyze the heap dump. Jhat will analyze the heap dump file and create a server instance for analysis. Use your browser, http://localhost:7000/ to see heap information such as heap histogram.

2. Include JVM options -XX:+PrintGCDetails

This command will print current GC details on application output. Good to know what is the current status of the GC.

3. JConsole

JConsole is an application that can help you monitor your application real time. You can use JConsole to connect local or remote application for application monitor and analyze.

See the following for more details

http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html
http://java.sun.com/developer/technicalArticles/J2SE/monitoring/#Insufficient_Memory

No comments:

Post a Comment

Hadoop - How to setup a Hadoop Cluster

Below is a step-by-step guide which I had used to setup a Hadoop Cluster Scenario 3 VMs involved: 1) NameNode, ResourceManager - Host...