SlideShare a Scribd company logo
MEMORY ANALYZER TOOL
BY
MOHAMMAD SAMIULLAH FAROOQUI
AGENDA
• Memory Analysis
• Some definitions
• Example of leak code
• Demo of MAT
Why use MAT
• Identify memory leaks
• Reduce memory consumption
Important Definitions
• Heap Dump
• Shallow Heap
• Retained Heap
• Dominator Tree
• Garbage Collection Roots
Heap Dump
• a snapshot of the memory of a Java process
• contains information about the java objects
and classes in the heap
1. All Objects - Class, fields, primitive values and references
2. All Classes - Classloader, name, super class, static fields
3. Garbage Collection Roots - Objects defined to be reachable by the JVM
4. Thread Stacks and Local Variables - The call-stacks of threads at the
moment of the snapshot, and per frame information about local
objects
• MAT works with HPROF binary heap dumps
How to acquire a Heap Dump
Shallow Heap
• memory consumed by one object
Retained Heap
• Retained set of X is the set of objects which
would be removed by GC when 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.
Object Reference Graph
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.
• The immediate dominator x of some object y
is the dominator closest to the object y.
Object graph to Dominator Tree
Garbage Collection Roots
• A garbage collection root is an object that is
accessible by the JVM(DVM in case of Android)
Examples:-
1. System Class(Class loaded by bootstrap/system class loader)
For example, java.util.*
2. Java Local(Local variable) For example, input parameters or
locally created objects of methods that are still in the stack
of a thread.
3. Finalizable - An object which is in a queue awaiting its
finalizer to be run.
How to analyze memory leaks
• Find the biggest objects
• Analyze why they are kept in memory
• Analyze what makes them big
How the leak analysis was done
• Got a “good” heap dump
• Found the biggest objects (in the dominator
tree)
• Analyzed who kept them alive (using paths)
• Analyzed what made them big (looking at
their retained set)
• Used “Leak Report” to automate the analysis
Inspect the thread to find its activity
• Look at the thread attributes -
name, class, etc...
• Look at the local variables
• Look at the stack of the thread
Find where memory usage can be
optimized
• Inspect the set of retained objects
• Search for inefficiently used data structures
• Look for redundant data
How memory usage was analyzed
• Analyzed retained objects (in dominator
tree, retained set)
• Used “Group by Value” to find redundant
objects
• Used the commands from the “Collections”
group
• Used “Component Report” to automate the
analysis
Thank You
Resource for slides taken from the following links
• http://www.slideshare.net/AJohnson1/practical-lessons-in-
memory-analysis#
• http://www.slideshare.net/littleeye/memory-analyzer-tool#
• http://help.eclipse.org/kepler/index.jsp?topic=/org.eclipse.m
at.ui.help/welcome.html

More Related Content

PPTX
Xray for Jira - How to automate your QA process
PDF
Robot framework and selenium2 library
PDF
Test Management & Automation with JIRA
PDF
Introduction to Jira - Bug Tracking tool
PPTX
Jira as a Test Management Tool
PPTX
TestOps and Shift Left
PPTX
API Test Automation Using Karate (Anil Kumar Moka)
Xray for Jira - How to automate your QA process
Robot framework and selenium2 library
Test Management & Automation with JIRA
Introduction to Jira - Bug Tracking tool
Jira as a Test Management Tool
TestOps and Shift Left
API Test Automation Using Karate (Anil Kumar Moka)

What's hot (20)

PDF
XRAY for Jira
PPTX
Reactive Spring 5
PPTX
Xray for Jira - Overview
PPTX
Cerberus Testing
PPTX
An Introduction to Performance Testing
PDF
Introduction To Jira
PDF
Karate - powerful and simple framework for REST API automation testing
PDF
Agile Test Management Using Jira and Zephyr
PPTX
Karate for Complex Web-Service API Testing by Peter Thomas
PDF
Testing Microservices
PDF
Introduction to JIRA & Agile Project Management
PPTX
The role of Business Analyst
PPT
TESTING STRATEGY.ppt
PPTX
Document management in Atlassian Confluence and Jira
PPTX
Jira as a Tool for Test Management
PPTX
Scripting robot
PPTX
Automation Framework Presentation
PPTX
Hacking the browser with puppeteer sharp .NET conf AR 2018
PDF
Performance testing with JMeter
XRAY for Jira
Reactive Spring 5
Xray for Jira - Overview
Cerberus Testing
An Introduction to Performance Testing
Introduction To Jira
Karate - powerful and simple framework for REST API automation testing
Agile Test Management Using Jira and Zephyr
Karate for Complex Web-Service API Testing by Peter Thomas
Testing Microservices
Introduction to JIRA & Agile Project Management
The role of Business Analyst
TESTING STRATEGY.ppt
Document management in Atlassian Confluence and Jira
Jira as a Tool for Test Management
Scripting robot
Automation Framework Presentation
Hacking the browser with puppeteer sharp .NET conf AR 2018
Performance testing with JMeter
Ad

Similar to Memory Analyzer Tool (MAT) (20)

PPTX
02D-Memory Management in Java.pptx
PPTX
Juggling with Bits and Bytes - How Apache Flink operates on binary data
PPTX
Javasession10
PPT
An Introduction to JVM Internals and Garbage Collection in Java
PPT
Practical lessons in memory analysis
PPT
Java programing considering performance
PDF
Memory Analysis of the Dalvik (Android) Virtual Machine
PPTX
/path/to/content - the Apache Jackrabbit content repository
PDF
java-monitoring-troubleshooting
PPTX
Exploring Java Heap Dumps (Oracle Code One 2018)
PDF
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
PPTX
DSpace 4.2 Transmission: Import/Export
PPT
Heap & thread dump
KEY
Big Search with Big Data Principles
PPTX
Garbage collection in C#,important topic
PPTX
Java and the JVM
PPT
Alfresco node lifecyle, services and zones
PDF
ModeShape 3 overview
PPT
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
02D-Memory Management in Java.pptx
Juggling with Bits and Bytes - How Apache Flink operates on binary data
Javasession10
An Introduction to JVM Internals and Garbage Collection in Java
Practical lessons in memory analysis
Java programing considering performance
Memory Analysis of the Dalvik (Android) Virtual Machine
/path/to/content - the Apache Jackrabbit content repository
java-monitoring-troubleshooting
Exploring Java Heap Dumps (Oracle Code One 2018)
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
DSpace 4.2 Transmission: Import/Export
Heap & thread dump
Big Search with Big Data Principles
Garbage collection in C#,important topic
Java and the JVM
Alfresco node lifecyle, services and zones
ModeShape 3 overview
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
Ad

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Approach and Philosophy of On baking technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPT
Teaching material agriculture food technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Programs and apps: productivity, graphics, security and other tools
Chapter 3 Spatial Domain Image Processing.pdf
Network Security Unit 5.pdf for BCA BBA.
sap open course for s4hana steps from ECC to s4
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Approach and Philosophy of On baking technology
Building Integrated photovoltaic BIPV_UPV.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Teaching material agriculture food technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Review of recent advances in non-invasive hemoglobin estimation
“AI and Expert System Decision Support & Business Intelligence Systems”
The AUB Centre for AI in Media Proposal.docx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx

Memory Analyzer Tool (MAT)

  • 1. MEMORY ANALYZER TOOL BY MOHAMMAD SAMIULLAH FAROOQUI
  • 2. AGENDA • Memory Analysis • Some definitions • Example of leak code • Demo of MAT
  • 3. Why use MAT • Identify memory leaks • Reduce memory consumption
  • 4. Important Definitions • Heap Dump • Shallow Heap • Retained Heap • Dominator Tree • Garbage Collection Roots
  • 5. Heap Dump • a snapshot of the memory of a Java process • contains information about the java objects and classes in the heap 1. All Objects - Class, fields, primitive values and references 2. All Classes - Classloader, name, super class, static fields 3. Garbage Collection Roots - Objects defined to be reachable by the JVM 4. Thread Stacks and Local Variables - The call-stacks of threads at the moment of the snapshot, and per frame information about local objects • MAT works with HPROF binary heap dumps
  • 6. How to acquire a Heap Dump
  • 7. Shallow Heap • memory consumed by one object
  • 8. Retained Heap • Retained set of X is the set of objects which would be removed by GC when 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.
  • 10. 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. • The immediate dominator x of some object y is the dominator closest to the object y.
  • 11. Object graph to Dominator Tree
  • 12. Garbage Collection Roots • A garbage collection root is an object that is accessible by the JVM(DVM in case of Android) Examples:- 1. System Class(Class loaded by bootstrap/system class loader) For example, java.util.* 2. Java Local(Local variable) For example, input parameters or locally created objects of methods that are still in the stack of a thread. 3. Finalizable - An object which is in a queue awaiting its finalizer to be run.
  • 13. How to analyze memory leaks • Find the biggest objects • Analyze why they are kept in memory • Analyze what makes them big
  • 14. How the leak analysis was done • Got a “good” heap dump • Found the biggest objects (in the dominator tree) • Analyzed who kept them alive (using paths) • Analyzed what made them big (looking at their retained set) • Used “Leak Report” to automate the analysis
  • 15. Inspect the thread to find its activity • Look at the thread attributes - name, class, etc... • Look at the local variables • Look at the stack of the thread
  • 16. Find where memory usage can be optimized • Inspect the set of retained objects • Search for inefficiently used data structures • Look for redundant data
  • 17. How memory usage was analyzed • Analyzed retained objects (in dominator tree, retained set) • Used “Group by Value” to find redundant objects • Used the commands from the “Collections” group • Used “Component Report” to automate the analysis
  • 18. Thank You Resource for slides taken from the following links • http://www.slideshare.net/AJohnson1/practical-lessons-in- memory-analysis# • http://www.slideshare.net/littleeye/memory-analyzer-tool# • http://help.eclipse.org/kepler/index.jsp?topic=/org.eclipse.m at.ui.help/welcome.html