Saturday, June 20, 2009

Memory leak in Java application


What are the first steps to do when notice that the newly developed Java application is not running continuously? Most of the time it may be due to memory leak.

First thing to do is study the memory usage/ thread creation patterns of the application. Different profiler tools are available in market for this.

Two tools I commonly use are
1. JProfiler
2. YourKit

In JProfiler - if there are memory leaks , total memory of the objects (which are leaking) will be shown against the class which created the memory.
Sometimes this may be misleading as the object references may be held by someone else , and that class is the real reason for the leak.

In my experience , identifying those classes were bit easier in YourKit.



No comments:

Post a Comment