Java SE 6 enhances memory leak analysis and detection by including a full stack trace in the java.lang.OutOfMemory exception and generating a fatal error log when the heap is full. In addition, a new JVM option allows to run a script when the heap is full.

The following table will explain the various tools available for diagnosing the problem in the JVM.


Problem Symptom Diagnostic Tools



















































Problem


Symptom


Tool

Insufficient memory OutOfMemoryError Java Heap Analysis Tool ( JHat )
Memory leaks Growing use of memory

Frequent garbage collection
Java Monitoring and Management Console ( JConsole )

JVM Statistical Monitoring Tool ( JStat )
  A class with a high growth rate

A class with an unexpected number of instances
Memory Map ( JMap )
  An object is being referenced unintentionally JConsole or JMap with JHat
Finalizers Objects are pending for finalization JConsole
Deadlocks Threads block on object monitor or java.util.concurrent locks JConsole

Stack Trace ( JStack )
Looping threads Thread CPU time is continuously increasing JConsole with JTop
High lock contention Thread with high contention statistics JConsole

The JVM is responsible for automatic memory management, which reclaims the unused memory for the application. If an application keeps a reference to an object that it no longer needed, the object cannot be garbage collected and will occupy space in the heap until the object is removed. Such unintentional object retention is referred to as a memory leak. If the application leaks large amounts of memory, it will eventually run out of memory, and an OutOfMemoryError will be thrown. In addition, garbage collection may take place more frequently as the application attempts to free up space, thus causing the application to slow down.

The Java Virtual Machine (JVM) has the following types of memory: Heap, Non-Heap, and Native. The below given the screen shot of the JConsole.


                    

Copyright © 2012 VisualBuilder. All rights reserved