SlideShare a Scribd company logo
Eclipse Memory Analyzer
Krasimir Semerdzhiev
Development Architect / SAP Labs Bulgaria
Agenda


Getting started
Get hands dirty
Q&A




© 2011 SAP AG. All rights reserved.   2
Getting started
Few assumptions


You’ve passed beyond “Hello World” in Java
Hello World apps tend not to require too much memory




You’ve gotten an OutOfMemoryError at least once in your life :)




You’re proficient already with Garbage Collection
Attended the previous BGOUG event GC session




© 2011 SAP AG. All rights reserved.                               3
Getting started
Memory analyzer basics


Works with heap dumps – live snapshots of:




© 2011 SAP AG. All rights reserved.          4
Getting started
How to get a heap dump


Non-Interactive
-XX:+HeapDumpOnOutOfMemoryError


On Demand
JDK1.4.2_12+ and -XX:+HeapDumpOnCtrlBreak
JDK6 and JConsole or VisualVM


On IBM VMs
     -Xdump:system:events=throw,filter=java/lang/OutOfMemoryError,
    request=exclusive+prepwalk


More…
http://wiki.eclipse.org/index.php/MemoryAnalyzer#Getting_a_Heap_Dump




© 2011 SAP AG. All rights reserved.                                    5
Getting started
Shallow vs. Retained heap


Shallow heap is the memory consumed by one object
Retained set of X is the set of objects that will be garbage collected if X is garbage
collected
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

                                       Set of elements    Retained Set
                                       C                  C, F, G, J
                                       K                  K
                                       C, K               C, F, G, J, K, I




© 2011 SAP AG. All rights reserved.                                                  6
Getting started
Dominator tree


An object x dominates an object y if every path in the object graph from the start (or the root)
 node to y must go through x.

In the dominator tree each object is the immediate dominator of its children, so
  dependencies between the objects are easily identified.




© 2011 SAP AG. All rights reserved.                                                           7
Getting started
Dominator tree




© 2011 SAP AG. All rights reserved.   8
Getting started
Java references – java.lang.ref
                                                                         Softly reachable


    Created                           Initialized   Strongly reachable                         Finalized

                                                                         Weakly reachable


Soft reference
                                                                                            Phantom reachable
GC will try to preserve the object
Will collect it prior to throwing OutOfMemoryError



Weak reference
GC is free to reclaim the object.


Phantom reference
Track object collections


© 2011 SAP AG. All rights reserved.                                                                             9
Getting started
GC roots in Java


Keeps the objects in heap from being collected by GC

    System Class                       Finalizer Queue    GC handle      Unknown

    JNI Local                           Unfinalized      Thread stack   Unreachable

   JNI Global                   Thread block    Thread   Busy Monitor




© 2011 SAP AG. All rights reserved.                                                   10
Getting started
What is a leak?




© 2011 SAP AG. All rights reserved.   11
Agenda


Getting started
Get hands dirty
Q&A




© 2011 SAP AG. All rights reserved.   12
Analyze memory consumption
Getting the heap dump: Setup


JConsole refuses to connect




© 2011 SAP AG. All rights reserved.   13
Analyze memory consumption



DEMO




© 2011 SAP AG. All rights reserved.   14
How to get involved?


Eclipse Home Page
        http://www.eclipse.org/mat/

Forum
                 eclipse.technology.memory-analyzer

Blog
                 http://dev.eclipse.org/blogs/memoryanalyzer




© 2011 SAP AG. All rights reserved.                            15
Questions?



Krasimir Semerdzhiev
krasimir.semerdzhiev@sap.com
Thank You!



Krasimir Semerdzhiev
krasimir.semerdzhiev@sap.com

More Related Content

PDF
OSGI in Java EE servers:Sneak peak
PPT
Model Driven Method Engineering
PPTX
Memory Analyzer Tool (MAT)
PDF
Eclipse Memory Analyzer Tool
PPT
Energy efficiency of android
PDF
JavaOne 2010: OSGI Migrat
PPT
Eclipse Memory Analyzer - More Than Just a Heap Walker
PDF
SAP HANA Cloud Platform: The void between your Datacenter and the Cloud
OSGI in Java EE servers:Sneak peak
Model Driven Method Engineering
Memory Analyzer Tool (MAT)
Eclipse Memory Analyzer Tool
Energy efficiency of android
JavaOne 2010: OSGI Migrat
Eclipse Memory Analyzer - More Than Just a Heap Walker
SAP HANA Cloud Platform: The void between your Datacenter and the Cloud

Similar to [BGOUG] Memory analyzer (20)

PPTX
JVM: A Platform for Multiple Languages
PPT
A path to modularity with Eclipse Virgo
PDF
In The Future We All Use Symfony2
PPT
The Right Pill for JRuby Memory and Thread Issues: Eclipse Memory Analyzer
PDF
Gemini WEB and Virgo
PDF
Java notes | All Basics |
KEY
Java 7: Fork/Join, Invokedynamic and the future
PDF
Java: Rumours of my demise are greatly exaggerated
PDF
OSGi in Java EE Servers - Sneak Peek Under the Hood - Krasimir Semerdzhiev
PDF
IBM Java PackedObjects
PPTX
#JavaOne What's in an object?
PPTX
JavaOne2015-What's in an Object?
PPT
Efficient Memory and Thread Management in Highly Parallel Java Applications
PPTX
1 .java basic
PDF
55j7
PPT
JavaYDL18
PDF
A quick view about Java Virtual Machine
PPT
01Slide.ppt java indroduction chapter1 aaaaaaaa
PPTX
Avro - More Than Just a Serialization Framework - CHUG - 20120416
PDF
The Forces Driving Java
JVM: A Platform for Multiple Languages
A path to modularity with Eclipse Virgo
In The Future We All Use Symfony2
The Right Pill for JRuby Memory and Thread Issues: Eclipse Memory Analyzer
Gemini WEB and Virgo
Java notes | All Basics |
Java 7: Fork/Join, Invokedynamic and the future
Java: Rumours of my demise are greatly exaggerated
OSGi in Java EE Servers - Sneak Peek Under the Hood - Krasimir Semerdzhiev
IBM Java PackedObjects
#JavaOne What's in an object?
JavaOne2015-What's in an Object?
Efficient Memory and Thread Management in Highly Parallel Java Applications
1 .java basic
55j7
JavaYDL18
A quick view about Java Virtual Machine
01Slide.ppt java indroduction chapter1 aaaaaaaa
Avro - More Than Just a Serialization Framework - CHUG - 20120416
The Forces Driving Java
Ad

More from SAP HANA Cloud Platform (14)

PDF
SAP Hack2Build hackathon - SAP Commerce Cloud & Kyma runtime
PDF
Gardener: Managed Kubernetes on Your Terms
PDF
Kyma: Extending Business systems with Kubernetes, Istio and <fill the blank>.
PDF
Using Kubernetes to Extend Enterprise Software
PDF
Kubernetes, Istio and Knative - noteworthy practical experience
PDF
Options for running Kubernetes at scale across multiple cloud providers
PDF
SAP DKOM 2016 | 30154 | SAP HCP Cloud Extensions Intro
PDF
SAP TechEd 2015 | DEV109 | Extending Cloud Solutions from SAP using SAP HANA ...
PDF
SAP D-Code/TechEd 2014|DEV203|Extending SuccessFactors using SAP HANA Cloud P...
PDF
SAP TechEd 2013: CD105: Extending SuccessFactors EmployeeCentral with apps on...
PDF
SAP HANA Cloud Platform Community BOF @ Devoxx 2013
PDF
SAP HANA Cloud: From Your Datacenter to the Cloud and Back
PDF
[BGOUG] Java GC - Friend or Foe
PDF
Eclipse Open Source @ SAP
SAP Hack2Build hackathon - SAP Commerce Cloud & Kyma runtime
Gardener: Managed Kubernetes on Your Terms
Kyma: Extending Business systems with Kubernetes, Istio and <fill the blank>.
Using Kubernetes to Extend Enterprise Software
Kubernetes, Istio and Knative - noteworthy practical experience
Options for running Kubernetes at scale across multiple cloud providers
SAP DKOM 2016 | 30154 | SAP HCP Cloud Extensions Intro
SAP TechEd 2015 | DEV109 | Extending Cloud Solutions from SAP using SAP HANA ...
SAP D-Code/TechEd 2014|DEV203|Extending SuccessFactors using SAP HANA Cloud P...
SAP TechEd 2013: CD105: Extending SuccessFactors EmployeeCentral with apps on...
SAP HANA Cloud Platform Community BOF @ Devoxx 2013
SAP HANA Cloud: From Your Datacenter to the Cloud and Back
[BGOUG] Java GC - Friend or Foe
Eclipse Open Source @ SAP
Ad

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
KodekX | Application Modernization Development
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Spectroscopy.pptx food analysis technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Review of recent advances in non-invasive hemoglobin estimation
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
KodekX | Application Modernization Development
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Spectroscopy.pptx food analysis technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

[BGOUG] Memory analyzer

  • 1. Eclipse Memory Analyzer Krasimir Semerdzhiev Development Architect / SAP Labs Bulgaria
  • 2. Agenda Getting started Get hands dirty Q&A © 2011 SAP AG. All rights reserved. 2
  • 3. Getting started Few assumptions You’ve passed beyond “Hello World” in Java Hello World apps tend not to require too much memory You’ve gotten an OutOfMemoryError at least once in your life :) You’re proficient already with Garbage Collection Attended the previous BGOUG event GC session © 2011 SAP AG. All rights reserved. 3
  • 4. Getting started Memory analyzer basics Works with heap dumps – live snapshots of: © 2011 SAP AG. All rights reserved. 4
  • 5. Getting started How to get a heap dump Non-Interactive -XX:+HeapDumpOnOutOfMemoryError On Demand JDK1.4.2_12+ and -XX:+HeapDumpOnCtrlBreak JDK6 and JConsole or VisualVM On IBM VMs -Xdump:system:events=throw,filter=java/lang/OutOfMemoryError, request=exclusive+prepwalk More… http://wiki.eclipse.org/index.php/MemoryAnalyzer#Getting_a_Heap_Dump © 2011 SAP AG. All rights reserved. 5
  • 6. Getting started Shallow vs. Retained heap Shallow heap is the memory consumed by one object Retained set of X is the set of objects that will be garbage collected if X is garbage collected 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 Set of elements Retained Set C C, F, G, J K K C, K C, F, G, J, K, I © 2011 SAP AG. All rights reserved. 6
  • 7. Getting started Dominator tree An object x dominates an object y if every path in the object graph from the start (or the root) node to y must go through x. In the dominator tree each object is the immediate dominator of its children, so dependencies between the objects are easily identified. © 2011 SAP AG. All rights reserved. 7
  • 8. Getting started Dominator tree © 2011 SAP AG. All rights reserved. 8
  • 9. Getting started Java references – java.lang.ref Softly reachable Created Initialized Strongly reachable Finalized Weakly reachable Soft reference Phantom reachable GC will try to preserve the object Will collect it prior to throwing OutOfMemoryError Weak reference GC is free to reclaim the object. Phantom reference Track object collections © 2011 SAP AG. All rights reserved. 9
  • 10. Getting started GC roots in Java Keeps the objects in heap from being collected by GC System Class Finalizer Queue GC handle Unknown JNI Local Unfinalized Thread stack Unreachable JNI Global Thread block Thread Busy Monitor © 2011 SAP AG. All rights reserved. 10
  • 11. Getting started What is a leak? © 2011 SAP AG. All rights reserved. 11
  • 12. Agenda Getting started Get hands dirty Q&A © 2011 SAP AG. All rights reserved. 12
  • 13. Analyze memory consumption Getting the heap dump: Setup JConsole refuses to connect © 2011 SAP AG. All rights reserved. 13
  • 14. Analyze memory consumption DEMO © 2011 SAP AG. All rights reserved. 14
  • 15. How to get involved? Eclipse Home Page http://www.eclipse.org/mat/ Forum eclipse.technology.memory-analyzer Blog http://dev.eclipse.org/blogs/memoryanalyzer © 2011 SAP AG. All rights reserved. 15