Eclipse Memory Analyzer - More Than Just a Heap Walker


Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Eclipse Memory Analyzer - More Than Just a Heap Walker

  1. 1. Eclipse Memory Analyzer – More Than Just a Heap Walker Andrew Johnson (IBM) Elena Nayashkova (SAP)
  2. 2. Introduction <ul><li>The number of memory-related problems is very high </li></ul><ul><li>They are extremely difficult to analyze </li></ul><ul><li>Analysis requires expertise in the analyzed code </li></ul><ul><li>Eclipse Memory Analyzer: </li></ul><ul><ul><li>Simplifies memory analysis </li></ul></ul><ul><ul><li>Extensible </li></ul></ul><ul><ul><li>Free for download @ </li></ul></ul>
  3. 3. A Little Bit of History <ul><li>Problem #1: multi-GB heap dumps from 64-bit machines </li></ul><ul><ul><li>Quickly open and re-open a heap dump on 32-bit machines </li></ul></ul><ul><li>Problem #2: millions of objects. Where is the „needle“? </li></ul><ul><ul><li>Dominator Tree: fast calculation of retained memory </li></ul></ul><ul><ul><li>Meaningful names for class loaders: see components </li></ul></ul><ul><ul><li>SQL-like language: create custom queries </li></ul></ul><ul><li>Problem #3: complexity of analysis </li></ul><ul><ul><li>Reports on memory leak suspects and checks for known antipatterns </li></ul></ul><ul><li>Problem #4: HPROF heap dumps only </li></ul><ul><ul><li>Support for IBM system dumps </li></ul></ul>
  4. 4. Agenda <ul><li>Support for IBM System Dumps </li></ul><ul><li>Automated Analysis </li></ul><ul><li>Equinox OSGi Bundle Explorer </li></ul>
  5. 5. IBM Dumps <ul><li>IBM VM dumps differ from Sun VM dumps </li></ul><ul><li>Need a VM option to get system dump on OutOfMemory </li></ul><ul><li>System dumps are postprocessed with JExtract </li></ul><ul><li>Adapter for MAT available from IBM to read these dumps </li></ul><ul><li>Adapter uses Diagnostic Tooling Interface for Java (DTFJ) to read the dumps, then passes data to MAT </li></ul><ul><li>DTFJ isolates differences between dumps from different levels of IBM VMs </li></ul>
  6. 6. Demo <ul><li>DTFJ – adapter </li></ul><ul><ul><li>Acquire and open an IBM heap dump </li></ul></ul><ul><ul><li>Run application with dump option java -Xdump:system:events=throw,filter=java/lang/OutOfMemoryError </li></ul></ul><ul><ul><li>Postprocess dump to add extra VM data jextract <name of dump> .dmp </li></ul></ul><ul><ul><li>Open the jextract-ed file in Memory Analyzer and analyze as Sun heap dump </li></ul></ul>
  7. 7. Demo <ul><li>Memory Leak Hunter </li></ul><ul><ul><li>Automatically detect memory leak suspects </li></ul></ul><ul><ul><li>Discover if the issue is known (and a fix available) </li></ul></ul><ul><ul><li>Collect details for in depth analysis by the code experts </li></ul></ul>
  8. 8. Report Overview Any up-to-date architecture loads components with separate class loaders, be it OSGi or JEE application servers. Extensible to display meaningful names. Classification for trouble ticket system: less ping-pong of trouble tickets. Search by keywords: identify if problem is known One big object: memory leak suspect
  9. 9. Report Details Accumulated objects A significant drop in the retained sizes shows the accumulation point The chain of objects and references which keep the suspect alive
  10. 10. Demo <ul><li>Top Components Report </li></ul><ul><ul><li>Analyze components, that occupy more memory, than a certain threshold </li></ul></ul><ul><ul><li>Give hints where memory footprint can be optimized </li></ul></ul><ul><ul><li>Check for known antipatterns </li></ul></ul>
  11. 11. Report Details
  12. 12. Report Details
  13. 13. Equinox OSGi Bundle Explorer <ul><li>Core runtime of Eclipse uses Equinox OSGi framework. A plug-in is an OSGi bundle. </li></ul><ul><li>For each bundle present in your Equinox-based application Memory Analyzer’s Bundle Explorer shows: </li></ul><ul><ul><li>name and version </li></ul></ul><ul><ul><li>state and location </li></ul></ul><ul><ul><li>dependencies and dependents </li></ul></ul><ul><ul><li>services contributed and consumed </li></ul></ul><ul><ul><li>extension points and extensions </li></ul></ul><ul><ul><li>hosted bundle fragments </li></ul></ul>
  14. 14. Demo <ul><li>Equinox OSGi Bundle </li></ul><ul><li>Explorer </li></ul><ul><ul><li>Show the state of all bundles in the analyzed application </li></ul></ul><ul><ul><li>What other bundles does my bundle depend on at runtime? </li></ul></ul><ul><ul><li>Detect duplicate bundles </li></ul></ul>
  15. 15. What’s Next? <ul><li>Compare multiple heap dumps </li></ul><ul><li>Acquire heap dumps interactively </li></ul><ul><li>Become part of Galileo Simultaneous Release </li></ul>
  16. 16. Thank You! <ul><li>Memory Analyzer @ Eclipse: </li></ul><ul><li> </li></ul><ul><li>IBM DTFJ-adapter for Eclipse Memory Analyzer: </li></ul><ul><li> </li></ul><ul><li>Memory Analyzer Wiki @ SAP: </li></ul><ul><li> =/display/Java/ Java+Memory+Analysis </li></ul><ul><li>Blogs: </li></ul><ul><li> </li></ul>
  17. 17. Binary Heap Dump <ul><li>A heap dump is a snapshot of objects that are alive at one point in time. </li></ul><ul><li> It contains: </li></ul><ul><ul><ul><ul><ul><li>Objects: fields, references, primitive values, … </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Classes: class loader, super class, static fields, … </li></ul></ul></ul></ul></ul><ul><ul><ul><li> A heap dump does not contain </li></ul></ul></ul><ul><ul><ul><ul><ul><li>where the objects have been created </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>which objects have been garbage collected </li></ul></ul></ul></ul></ul>For Your Reference IOIOII IOIIOI OIOIO IIOIIOI IOIOII IOIIOI OIOIO IIOIIOI
  18. 18. How to Get a Heap Dump <ul><li>Non-Interactive </li></ul><ul><ul><li>-XX:+HeapDumpOnOutOfMemoryError </li></ul></ul><ul><li>On Demand </li></ul><ul><ul><li>JDK1.4.2_12 and -XX:+HeapDumpOnCtrlBreak </li></ul></ul><ul><ul><li>JDK6 and Jconsole </li></ul></ul><ul><li>More… </li></ul><ul><ul><li> </li></ul></ul>For Your Reference
  19. 19. Shallow and Retained Size <ul><li>Shallow heap is the memory consumed by one object </li></ul><ul><li>Retained set of X is the set of objects that will be garbage collected if X is garbage collected </li></ul><ul><li>Retained heap of X is the sum of shallow sizes of all objects in the retained set of X , i.e. memory kept alive by X </li></ul>For Your Reference Set of elements Retained Set C C, F, G, J K K C, K C, F, G, J, K, I
  20. 20. Dominator Tree <ul><li>The Dominator Tree is a Transformation of the Cyclic Object Graph into a “Keep-Alive” Tree: </li></ul><ul><ul><li>Every node in the Tree is directly responsible for keeping alive its children </li></ul></ul><ul><ul><li>Object X dominates object Y if all paths from the roots to Y run through X </li></ul></ul>For Your Reference <ul><li>Benefits: </li></ul><ul><li>Fast calculation of the retained size (sum all children) </li></ul><ul><li>List of distinct big </li></ul><ul><li>objects (first level of the tree) </li></ul><ul><li>Fast identification of </li></ul><ul><li>responsible objects (just go up the tree) </li></ul>