Vladimir Pavlov Dimitar Giormov SAP Labs Bulgaria Using and Extending Memory Analyzer into Uncharted Waters Memory Analyzer
<ul><li>Introduction </li></ul><ul><ul><li>The Headaches </li></ul></ul><ul><ul><li>Eclipse Memory Analyzer </li></ul></ul...
<ul><li>Memory leaks </li></ul><ul><ul><li>Hard to debug and find the root cause </li></ul></ul><ul><ul><li>Eventually lea...
<ul><li>Eclipse Memory Analyzer  (MAT) is… </li></ul><ul><ul><li>Java heap analyzer </li></ul></ul><ul><ul><li>Helps find ...
 
<ul><li>Why extend MAT? </li></ul><ul><ul><li>To save time doing the same thing repeatedly </li></ul></ul><ul><ul><li>To h...
<ul><li>Isnapshot </li></ul><ul><ul><li>Represents a heap dump </li></ul></ul><ul><ul><li>Methods for reading classes and ...
<ul><li>Name Resolver </li></ul><ul><ul><li>Used to give meaningful descriptions of objects </li></ul></ul><ul><ul><li>Sim...
<ul><li>Parser – for new heap dump types and VMs, such as for Jikes RVM </li></ul><ul><li>Trigger Heap Dump – org.eclipse....
<ul><li>Ruby  is… </li></ul><ul><ul><li>Dynamic  scripting language </li></ul></ul><ul><ul><li>Object-oriented </li></ul><...
<ul><li>Adding JRuby into the picture… </li></ul>THE HEADACHES – AGGRAVATED © SAP 2010 / Page
 
<ul><li>What were the goals </li></ul><ul><ul><li>Identify memory leaks (critical when talking about embedded systems due ...
<ul><li>Implemented an Extension </li></ul><ul><ul><li>Extension point used:  org.eclipse.mat.ui </li></ul></ul><ul><ul><l...
<ul><li>The integration of MOTODEV Studio, Google DDMS and Eclipse MAT worked very well. </li></ul><ul><li>Used the  org.e...
<ul><li>Eclipse Memory Analyzer provides: </li></ul><ul><li>Powerful and efficient  memory analysis features out-of-the-bo...
RESOURCES © SAP 2010 / Page
THANK YOU! in:  vpavlov t:  @giormov Memory Analyzer
Upcoming SlideShare
Loading in …5
×

Using and Extending Memory Analyzer into Uncharted Waters

5,280
-1

Published on

Presentation given at EclipseCon 2011 in Santa Clara, CA, about using and extending the Eclipse Memory Analyzer (MAT). Session abstract at http://www.eclipsecon.org/2011/sessions/?page=sessions&id=2184

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,280
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
52
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Hprof is the file that MAT plugins are able to load and display memory reports Retained heap is the memory kept alive by a class X
  • CompositeHeapEditorPane is the base class for the pages inside MAT report OQLPane is a page that shows memory usage and have an edit field to filter classes in the report using a syntax similar to SQL (called OQL – object query language) MotodevPane (see picture) generates the filter selecting the Android application package (e.g.: the statement with “com.a.*” for the user).
  • It would be interesting to mention that in the 2-week time, we also p rovided methods to pull MAT files from phone/emulator integrated into our Device Manager view
  • Using and Extending Memory Analyzer into Uncharted Waters

    1. 1. Vladimir Pavlov Dimitar Giormov SAP Labs Bulgaria Using and Extending Memory Analyzer into Uncharted Waters Memory Analyzer
    2. 2. <ul><li>Introduction </li></ul><ul><ul><li>The Headaches </li></ul></ul><ul><ul><li>Eclipse Memory Analyzer </li></ul></ul><ul><li>Extending Eclipse Memory Analyzer </li></ul><ul><ul><li>API and Extension Points </li></ul></ul><ul><ul><li>JRuby Case </li></ul></ul><ul><ul><li>Android Apps Case </li></ul></ul><ul><li>Q & A </li></ul>© SAP 2010 / Page
    3. 3. <ul><li>Memory leaks </li></ul><ul><ul><li>Hard to debug and find the root cause </li></ul></ul><ul><ul><li>Eventually lead to OOM errors </li></ul></ul><ul><ul><li> Brings your system down </li></ul></ul><ul><ul><li> Often not reproducible </li></ul></ul><ul><li>Thread issues </li></ul><ul><ul><li>Deadlocks </li></ul></ul><ul><ul><li>Exhausted threads </li></ul></ul><ul><ul><li>Waiting for an external resource – e.g. DB connection </li></ul></ul><ul><ul><li> Application does not respond </li></ul></ul><ul><ul><li> Whole system hangs </li></ul></ul>THE HEADACHES © SAP 2010 / Page
    4. 4. <ul><li>Eclipse Memory Analyzer (MAT) is… </li></ul><ul><ul><li>Java heap analyzer </li></ul></ul><ul><ul><li>Helps find memory leaks and reduce memory consumption </li></ul></ul><ul><ul><li>UI and programmatic access to data in the heap dumps </li></ul></ul><ul><ul><li>Multi-Gigabyte Java Heap Dumps Are Nothing to Fear Now </li></ul></ul><ul><ul><li>Soooo much faster than other tools, e.g. jhat </li></ul></ul><ul><ul><li>Very little memory “overhead” for processing heap dumps (again – cf. jhat) </li></ul></ul><ul><ul><li>Supports Sun, SAP, HP, IBM JDKs 1.4.2 and above </li></ul></ul><ul><ul><li>Automatic problem recognition </li></ul></ul><ul><ul><li>Could also process thread dumps and correlate data to provide additional details </li></ul></ul><ul><ul><li>Initial contribution from SAP, joined by IBM </li></ul></ul><ul><ul><li>Highly extensible </li></ul></ul>ECLIPSE MEMORY ANALYZER © SAP 2010 / Page Memory Analyzer
    5. 6. <ul><li>Why extend MAT? </li></ul><ul><ul><li>To save time doing the same thing repeatedly </li></ul></ul><ul><ul><li>To help others use the same technique as you </li></ul></ul><ul><ul><li>To do things not possible from the GUI </li></ul></ul><ul><ul><li>To build in application or domain specific logic </li></ul></ul><ul><li>How to extend MAT? </li></ul><ul><ul><li>MAT provides a set of Eclipse extension points </li></ul></ul><ul><ul><li>User writes an extension plug-in </li></ul></ul><ul><ul><li>MAT provides an API for reading data from a heap dump </li></ul></ul>EXTENDING MAT © SAP 2010 / Page
    6. 7. <ul><li>Isnapshot </li></ul><ul><ul><li>Represents a heap dump </li></ul></ul><ul><ul><li>Methods for reading classes and objects, getting sizes, GC roots, referenced objects, etc. </li></ul></ul><ul><li>Object model </li></ul><ul><ul><li>IClass </li></ul></ul><ul><ul><li>IObject </li></ul></ul><ul><ul><ul><li>IInstance </li></ul></ul></ul><ul><ul><ul><ul><li>IClassLoader </li></ul></ul></ul></ul><ul><ul><ul><li>IArray </li></ul></ul></ul><ul><ul><ul><ul><li>IPrimitiveArray </li></ul></ul></ul></ul><ul><ul><ul><ul><li>IObjectArray </li></ul></ul></ul></ul>PROGRAMMATIC ACCESS TO A SNAPSHOT © SAP 2010 / Page
    7. 8. <ul><li>Name Resolver </li></ul><ul><ul><li>Used to give meaningful descriptions of objects </li></ul></ul><ul><ul><li>Similar to a toString() method </li></ul></ul><ul><ul><li>Extension point: org.eclipse.mat.api.nameResolver </li></ul></ul><ul><li>Query </li></ul><ul><ul><li>Used for exploring dumps or detailed analysis </li></ul></ul><ul><ul><li>Result in the form of a table, tree, histogram, pie chart, free text... </li></ul></ul><ul><ul><li>Integrated into MAT’s menus </li></ul></ul><ul><ul><li>“ Collaboration” of queries </li></ul></ul><ul><ul><li>Extension point: org.eclipse.mat.report.query </li></ul></ul><ul><li>Request Resolver </li></ul><ul><ul><li>Used to provide details about what a thread was doing </li></ul></ul><ul><ul><li>Contributes to Leak Suspects report </li></ul></ul><ul><ul><li>Extension point: org.eclipse.mat.api.requestResolver </li></ul></ul>EXTENSION POINTS © SAP 2010 / Page
    8. 9. <ul><li>Parser – for new heap dump types and VMs, such as for Jikes RVM </li></ul><ul><li>Trigger Heap Dump – org.eclipse.mat.api.heapDumpProvider </li></ul><ul><ul><li>For new VM types </li></ul></ul><ul><li>Reports – org.eclipse.mat.report.report </li></ul><ul><ul><li>HTML results of queries – also used for batch mode </li></ul></ul><ul><li>Thread Resolver – additional thread data such as native stacks </li></ul><ul><li>Ticket Resolver – can identify appropriate routing for problems </li></ul><ul><ul><li>Based on classes and class loaders of problematic objects </li></ul></ul><ul><li>Rendering – org.eclipse.mat.api.renderer </li></ul><ul><ul><li>Additional to HTML and CSV </li></ul></ul><ul><li>Annotations used as filters and for configuration </li></ul>EXTENSION POINTS (CONTD.) © SAP 2010 / Page
    9. 10. <ul><li>Ruby is… </li></ul><ul><ul><li>Dynamic scripting language </li></ul></ul><ul><ul><li>Object-oriented </li></ul></ul><ul><ul><li>Focus on simplicity and productivity </li></ul></ul><ul><ul><li>Elegant syntax, natural to read and easy to write </li></ul></ul><ul><li>JRuby is… </li></ul><ul><ul><li>100% Java implementation of the Ruby programming language </li></ul></ul><ul><ul><li>Interpreter running atop the JVM </li></ul></ul><ul><ul><li>Generating Java bytecode (JIT compilation mode) </li></ul></ul><ul><ul><li>Tight integration with Java </li></ul></ul>RUBY AND JRUBY © SAP 2010 / Page
    10. 11. <ul><li>Adding JRuby into the picture… </li></ul>THE HEADACHES – AGGRAVATED © SAP 2010 / Page
    11. 13. <ul><li>What were the goals </li></ul><ul><ul><li>Identify memory leaks (critical when talking about embedded systems due to hardware restrictions) </li></ul></ul><ul><ul><li>Filter memory usage by classes belonging to the users’ application </li></ul></ul><ul><ul><li>Simpler workflow: developers start analyzing by classes they already know (not Android system classes) </li></ul></ul><ul><li>Why MAT was chosen </li></ul><ul><ul><li>The MAT perspective provides views to analyze application status, identify leaks, and so on, given an HPROF file </li></ul></ul><ul><ul><li>Reports are easy to navigate and provide information about retained heap </li></ul></ul><ul><ul><li>It is Eclipse based </li></ul></ul><ul><ul><li>Android supports the creation and extraction of HPROF files </li></ul></ul>MAT INTEGRATION WITH MOTODEV STUDIO
    12. 14. <ul><li>Implemented an Extension </li></ul><ul><ul><li>Extension point used: org.eclipse.mat.ui </li></ul></ul><ul><ul><li>Added a new page extending CompositeHeapEditorPane </li></ul></ul><ul><li>Created MotodevPane based on OQLPane class </li></ul>WORK DONE ON MAT
    13. 15. <ul><li>The integration of MOTODEV Studio, Google DDMS and Eclipse MAT worked very well. </li></ul><ul><li>Used the org.eclipse.mat.ui extension point, which was well-documented. </li></ul><ul><li>It took about 2 weeks of one developer to study the project, implement and test the solution. </li></ul>OVERALL EXPERIENCE
    14. 16. <ul><li>Eclipse Memory Analyzer provides: </li></ul><ul><li>Powerful and efficient memory analysis features out-of-the-box </li></ul><ul><li>API for extracting data from a heap dump </li></ul><ul><li>Application or domain specific analysis can be added as extensions </li></ul>SUMMARY © SAP 2010 / Page
    15. 17. RESOURCES © SAP 2010 / Page
    16. 18. THANK YOU! in: vpavlov t: @giormov Memory Analyzer
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×