Monday, November 15, 2010

Analysing Java Heap For Memory Leak


Analysing Heap dump - Two Examples: With memory leak, Without memory leak
· When to take a heap dump?
· Is it apt to take it when FullGC happens? (yes to observe more accurately.. pls refer to above stmnt on’confirm’ mem leak and below illustrated examples)
· How to say there is most probable leak in slow increasing heap applications ? (pls follow below examples..)


GC Type: 'Copy' for YGC and 'MarkSweepCompact' for tenured GC
In the Heap graph to a certain threshold, there were no FullGC events observed.. you can not notice them whether its FGC or just a tenured collection just by looking at the grapgh !.. Any way, by taking support from verbosegc, the non forced FGC happend after half-way through..







                                          (Please click on the images to view more closer)







                                                        And look at my next blog for no mem leak case...

3 comments:

  1. Java and to some degree .Net are the main choices because they have been consistently pegged as the “safe” choice to go with for mid-level project managers in the corporate world. No one was ever fired for choosing Java or Microsoft.

    However, there are many large distributed applications these days that run primarily with technologies like Python, PHP, et al. Even companies like Google and Yahoo are heavily invested in these technologies. Java may be the main choice for enterprise development now, but it’s days are numbered as the only stalwart option to go with.

    Let’s face it, many of these so called “enterprise applications” could easily have been written much faster and with less overhead using technologies like Python, PHP, et al.







    OpenCL Training

    ReplyDelete
  2. Good post.
    i have been trying to analyze a mem leak issue in my app for the past 1 week. Will J2EE diag help in identifying the leaky objects? Can you suggest any Heap dump analyzer tool to drill down to the object level?

    Thanks
    Anna

    ReplyDelete
  3. Yes HP's J2EE daig. definitely helps. And you can even use JVisualVM for analysing the heap dump.

    Take the heap dump of the jvm - use jmap for that.. and then load the heap dump into jvisualvm (which you can find in the bin directory of latest jdk (6) or u can downld it...

    And just follow the above approach to identify the exact mem leak and the package of your code that is leaking and the objects which are getting leaked...

    ReplyDelete