SlideShare a Scribd company logo
Practical Lessons in
Memory Analysis
Andrew Johnson
advisory software engineer
IBM United Kingdom Limited
2
Based on TS-4118 at JavaOne 2009
Original presentation by
• Krum Tsvetkov - SAP AG
• Andrew Johnson – IBM United Kingdom Limited
3
Goal
Learn practical tips and tricks for the
analysis of common memory-related
problems
4
Agenda
Introduction
Analyzing Memory Leaks
Analyzing a Heavy Request
Reducing Memory Footprint
Non-heap Memory
Summary
Q & A
5
Why care about memory?
Memory is a crucial resource
Excessive memory usage can cause:
• Crashes in the application
• Unresponsive applications
• Unpredictable program behavior
Memory analysis is complicated
6
How will this session help me?
Present common memory-related issues
Give hints how to solve them using heap
dumps and Memory Analyzer
Show many demonstrations using real-life
heap dumps
Show how to simplify analysis by
automating it
7
Heap dumps are useful for analysis
Heap dumps come “for free”
They are suitable for production
The comprehensive data allows detailed
analysis
There is wide platform coverage
• HPROF dumps from HotSpot based JVMs
• DTFJ system dumps from IBM JVMs
• Portable Heap Dumps (PHD) file from IBM JVMs
JSR-326/Apache Kato standardization
• http://incubator.apache.org/projects/kato.html
8
Agenda
Introduction
Analyzing Memory Leaks
Analyzing a Heavy Request
Reducing Memory Footprint
Non-heap Memory
Summary
Q & A
9
First, collect data for analysis
Enable heap dumps on OutOfMemoryError
Trigger heap dumps on demand if needed
How-to for getting a heap dump:
http://wiki.eclipse.org/index.php/MemoryAnalyzer#Gett
10
How to get a “good” heap dump
 When memory is exhausted the leak will occupy
most of the processing space
 Ensure big enough processing space, this will make
the leak easier to find
Max
Heap
Min
Heap
Processing
Space
Base
Memory
11
How to analyze memory leaks
Find the biggest objects
Analyze why they are kept in memory
Analyze what makes them big
12
Demonstration
 Analysis of a Memory Leak
13
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
14
Agenda
Introduction
Analyzing Memory Leaks
Analyzing a Heavy Request
Reducing Memory Footprint
Non-heap Memory
Summary
Q & A
15
What is a heavy request?
An expensive operation which can cause an
OutOfMemoryError
“Acute” rather than a “chronic” problem
Examples:
• Reading a big file in memory not in chunks
• Try to load a whole DB table in memory
16
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
17
Demonstration
Analysis of a Heavy Request
18
How thread activity was analyzed
Inspected thread attributes and local
variables (in object explorer)
Analyzed stack trace
19
Agenda
Introduction
Analyzing Memory Leaks
Analyzing a Heavy Request
Reducing Memory Footprint
Non-heap Memory
Summary
Q & A
20
Why is memory footprint important?
 A lower memory footprint can improve:
• The scaling of an application / server
• Performance by increasing the time between GCs
Max
Heap
Min
Heap
Processing
Space
Base
Memory
21
Find where footprint can be optimized
Inspect the set of retained objects
Search for inefficiently used data structures
Look for redundant data
22
Demonstration
• Analysis of High Memory Footprint
23
How memory footprint 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
24
Agenda
Introduction
Analyzing Memory Leaks
Analyzing a Heavy Request
Reducing Memory Footprint
Non-heap Memory
Summary
Q & A
25
Non-heap memory can be exhausted
What is in the non-heap memory?
• Metadata for classes
• Interned Strings (for some JVMs)
• NIO direct byte buffers
• Bitmaps
How can it be exhausted?
• Too many interned Strings
• Classes packaged and loaded multiple times
• Class loaders which are not properly released
26
Why is a class loader not released?
 The trivial case – there
is a “normal” reference
to it
 A common case – it is
the context class loader
of a thread
 The registry problem –
one instance is enough
Class loader
Class Class
Instance Instance Instance InstanceInstance
Registry
Root
27
How to analyze “leaking” class loaders
Find classes loaded more than once
Find redundant loaders by their name
Look at the paths to the suspect class
loaders
28
Demonstration
Analysis of “Leaking” Class Loaders
29
How “leaking” class loaders analysis was done
Used the “Duplicate Classes” query
Found the loaders that load redundant
classes
Analyzed why they are not released (using
paths)
30
Agenda
Introduction
Analyzing Memory Leaks
Analyzing a Heavy Request
Reducing Memory Footprint
Non-heap Memory
Summary
Q & A
31
Summary
Heap dumps are very helpful for memory
analysis
Memory Analyzer offers rich analysis feature
set
The analysis can often be automated
32
Questions and answers
Memory Analyzer homepage @ Eclipse
• http://www.eclipse.org/mat/
• Binary downloads
• Source downloads
• Forum
• Getting started guide
• Frequently asked questions
• Bug reports
33
Thank you
Andrew Johnson
• IBM United Kingdom Limited
Memory Analyzer homepage @ Eclipse
• http://www.eclipse.org/mat/
IBM Support Assistant
• http://www-01.ibm.com/software/support/isa/
• IBM Monitoring and Diagnostic Tools – Memory
Analyzer

More Related Content

What's hot

Gsummit apis-2013
Gsummit apis-2013Gsummit apis-2013
Gsummit apis-2013
Gluster.org
 
28 to 29 detection
28 to 29 detection 28 to 29 detection
28 to 29 detection myrajendra
 
Performance and predictability
Performance and predictabilityPerformance and predictability
Performance and predictability
RichardWarburton
 
Chainer Development Plan 2015/12
Chainer Development Plan 2015/12Chainer Development Plan 2015/12
Chainer Development Plan 2015/12
Seiya Tokui
 
Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Marcos García
 
Performance and predictability (1)
Performance and predictability (1)Performance and predictability (1)
Performance and predictability (1)
RichardWarburton
 
1 sample16c132 java-programming
1 sample16c132 java-programming1 sample16c132 java-programming
1 sample16c132 java-programming
Mary Jones
 
Text Classification in Python – using Pandas, scikit-learn, IPython Notebook ...
Text Classification in Python – using Pandas, scikit-learn, IPython Notebook ...Text Classification in Python – using Pandas, scikit-learn, IPython Notebook ...
Text Classification in Python – using Pandas, scikit-learn, IPython Notebook ...
Jimmy Lai
 
Oracle TKPROF Utility
Oracle TKPROF UtilityOracle TKPROF Utility
Oracle TKPROF Utility
Arun Sharma
 
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
Jannat Ruma
 
Java Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningJava Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningCarol McDonald
 

What's hot (13)

Gsummit apis-2013
Gsummit apis-2013Gsummit apis-2013
Gsummit apis-2013
 
28 to 29 detection
28 to 29 detection 28 to 29 detection
28 to 29 detection
 
Performance and predictability
Performance and predictabilityPerformance and predictability
Performance and predictability
 
Chainer Development Plan 2015/12
Chainer Development Plan 2015/12Chainer Development Plan 2015/12
Chainer Development Plan 2015/12
 
Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)
 
Performance and predictability (1)
Performance and predictability (1)Performance and predictability (1)
Performance and predictability (1)
 
1 sample16c132 java-programming
1 sample16c132 java-programming1 sample16c132 java-programming
1 sample16c132 java-programming
 
Text Classification in Python – using Pandas, scikit-learn, IPython Notebook ...
Text Classification in Python – using Pandas, scikit-learn, IPython Notebook ...Text Classification in Python – using Pandas, scikit-learn, IPython Notebook ...
Text Classification in Python – using Pandas, scikit-learn, IPython Notebook ...
 
Oracle TKPROF Utility
Oracle TKPROF UtilityOracle TKPROF Utility
Oracle TKPROF Utility
 
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
 
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
 
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
 
Java Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningJava Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and Tuning
 

Similar to Practical lessons in memory analysis

Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Haribabu Nandyal Padmanaban
 
Tachyon workshop 2015-07-19
Tachyon workshop 2015-07-19Tachyon workshop 2015-07-19
Tachyon workshop 2015-07-19
Tachyon Nexus, Inc.
 
Memory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineMemory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual Machine
Andrew Case
 
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Nikolay Savvinov
 
Distributed applications using Hazelcast
Distributed applications using HazelcastDistributed applications using Hazelcast
Distributed applications using Hazelcast
Taras Matyashovsky
 
TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012
Ashish Bhasin
 
2010 AIRI Petabyte Challenge - View From The Trenches
2010 AIRI Petabyte Challenge - View From The Trenches2010 AIRI Petabyte Challenge - View From The Trenches
2010 AIRI Petabyte Challenge - View From The TrenchesGeorge Ang
 
Java performance - not so scary after all
Java performance - not so scary after allJava performance - not so scary after all
Java performance - not so scary after all
Holly Cummins
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
Michael Yarichuk
 
Introduction to Recurrent Neural Network
Introduction to Recurrent Neural NetworkIntroduction to Recurrent Neural Network
Introduction to Recurrent Neural Network
Yan Xu
 
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
srisatish ambati
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
Ryan Cuprak
 
Tachyon-2014-11-21-amp-camp5
Tachyon-2014-11-21-amp-camp5Tachyon-2014-11-21-amp-camp5
Tachyon-2014-11-21-amp-camp5
Haoyuan Li
 
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
PostgreSQL-Consulting
 
MRT 2018: reflecting on the past and the present with temporal graph models
MRT 2018: reflecting on the past and the present with temporal graph modelsMRT 2018: reflecting on the past and the present with temporal graph models
MRT 2018: reflecting on the past and the present with temporal graph models
Antonio García-Domínguez
 
Profiling Web Archives
Profiling Web ArchivesProfiling Web Archives
Profiling Web Archives
Michael Nelson
 
Scam2011 syer
Scam2011 syerScam2011 syer
Scam2011 syerSAIL_QU
 
Performance Analysis of Idle Programs
Performance Analysis of Idle ProgramsPerformance Analysis of Idle Programs
Performance Analysis of Idle Programs
greenwop
 

Similar to Practical lessons in memory analysis (20)

Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
Tachyon workshop 2015-07-19
Tachyon workshop 2015-07-19Tachyon workshop 2015-07-19
Tachyon workshop 2015-07-19
 
Memory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineMemory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual Machine
 
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...
 
Distributed applications using Hazelcast
Distributed applications using HazelcastDistributed applications using Hazelcast
Distributed applications using Hazelcast
 
TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012
 
2010 AIRI Petabyte Challenge - View From The Trenches
2010 AIRI Petabyte Challenge - View From The Trenches2010 AIRI Petabyte Challenge - View From The Trenches
2010 AIRI Petabyte Challenge - View From The Trenches
 
Java performance - not so scary after all
Java performance - not so scary after allJava performance - not so scary after all
Java performance - not so scary after all
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
 
Introduction to Recurrent Neural Network
Introduction to Recurrent Neural NetworkIntroduction to Recurrent Neural Network
Introduction to Recurrent Neural Network
 
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
 
Tachyon-2014-11-21-amp-camp5
Tachyon-2014-11-21-amp-camp5Tachyon-2014-11-21-amp-camp5
Tachyon-2014-11-21-amp-camp5
 
Lecture semantic augmentation
Lecture semantic augmentationLecture semantic augmentation
Lecture semantic augmentation
 
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
 
MRT 2018: reflecting on the past and the present with temporal graph models
MRT 2018: reflecting on the past and the present with temporal graph modelsMRT 2018: reflecting on the past and the present with temporal graph models
MRT 2018: reflecting on the past and the present with temporal graph models
 
Profiling Web Archives
Profiling Web ArchivesProfiling Web Archives
Profiling Web Archives
 
Scam2011 syer
Scam2011 syerScam2011 syer
Scam2011 syer
 
Chapter 5 b
Chapter 5  bChapter 5  b
Chapter 5 b
 
Performance Analysis of Idle Programs
Performance Analysis of Idle ProgramsPerformance Analysis of Idle Programs
Performance Analysis of Idle Programs
 

Recently uploaded

AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 

Recently uploaded (20)

AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 

Practical lessons in memory analysis

  • 1. Practical Lessons in Memory Analysis Andrew Johnson advisory software engineer IBM United Kingdom Limited
  • 2. 2 Based on TS-4118 at JavaOne 2009 Original presentation by • Krum Tsvetkov - SAP AG • Andrew Johnson – IBM United Kingdom Limited
  • 3. 3 Goal Learn practical tips and tricks for the analysis of common memory-related problems
  • 4. 4 Agenda Introduction Analyzing Memory Leaks Analyzing a Heavy Request Reducing Memory Footprint Non-heap Memory Summary Q & A
  • 5. 5 Why care about memory? Memory is a crucial resource Excessive memory usage can cause: • Crashes in the application • Unresponsive applications • Unpredictable program behavior Memory analysis is complicated
  • 6. 6 How will this session help me? Present common memory-related issues Give hints how to solve them using heap dumps and Memory Analyzer Show many demonstrations using real-life heap dumps Show how to simplify analysis by automating it
  • 7. 7 Heap dumps are useful for analysis Heap dumps come “for free” They are suitable for production The comprehensive data allows detailed analysis There is wide platform coverage • HPROF dumps from HotSpot based JVMs • DTFJ system dumps from IBM JVMs • Portable Heap Dumps (PHD) file from IBM JVMs JSR-326/Apache Kato standardization • http://incubator.apache.org/projects/kato.html
  • 8. 8 Agenda Introduction Analyzing Memory Leaks Analyzing a Heavy Request Reducing Memory Footprint Non-heap Memory Summary Q & A
  • 9. 9 First, collect data for analysis Enable heap dumps on OutOfMemoryError Trigger heap dumps on demand if needed How-to for getting a heap dump: http://wiki.eclipse.org/index.php/MemoryAnalyzer#Gett
  • 10. 10 How to get a “good” heap dump  When memory is exhausted the leak will occupy most of the processing space  Ensure big enough processing space, this will make the leak easier to find Max Heap Min Heap Processing Space Base Memory
  • 11. 11 How to analyze memory leaks Find the biggest objects Analyze why they are kept in memory Analyze what makes them big
  • 13. 13 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
  • 14. 14 Agenda Introduction Analyzing Memory Leaks Analyzing a Heavy Request Reducing Memory Footprint Non-heap Memory Summary Q & A
  • 15. 15 What is a heavy request? An expensive operation which can cause an OutOfMemoryError “Acute” rather than a “chronic” problem Examples: • Reading a big file in memory not in chunks • Try to load a whole DB table in memory
  • 16. 16 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
  • 18. 18 How thread activity was analyzed Inspected thread attributes and local variables (in object explorer) Analyzed stack trace
  • 19. 19 Agenda Introduction Analyzing Memory Leaks Analyzing a Heavy Request Reducing Memory Footprint Non-heap Memory Summary Q & A
  • 20. 20 Why is memory footprint important?  A lower memory footprint can improve: • The scaling of an application / server • Performance by increasing the time between GCs Max Heap Min Heap Processing Space Base Memory
  • 21. 21 Find where footprint can be optimized Inspect the set of retained objects Search for inefficiently used data structures Look for redundant data
  • 22. 22 Demonstration • Analysis of High Memory Footprint
  • 23. 23 How memory footprint 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
  • 24. 24 Agenda Introduction Analyzing Memory Leaks Analyzing a Heavy Request Reducing Memory Footprint Non-heap Memory Summary Q & A
  • 25. 25 Non-heap memory can be exhausted What is in the non-heap memory? • Metadata for classes • Interned Strings (for some JVMs) • NIO direct byte buffers • Bitmaps How can it be exhausted? • Too many interned Strings • Classes packaged and loaded multiple times • Class loaders which are not properly released
  • 26. 26 Why is a class loader not released?  The trivial case – there is a “normal” reference to it  A common case – it is the context class loader of a thread  The registry problem – one instance is enough Class loader Class Class Instance Instance Instance InstanceInstance Registry Root
  • 27. 27 How to analyze “leaking” class loaders Find classes loaded more than once Find redundant loaders by their name Look at the paths to the suspect class loaders
  • 29. 29 How “leaking” class loaders analysis was done Used the “Duplicate Classes” query Found the loaders that load redundant classes Analyzed why they are not released (using paths)
  • 30. 30 Agenda Introduction Analyzing Memory Leaks Analyzing a Heavy Request Reducing Memory Footprint Non-heap Memory Summary Q & A
  • 31. 31 Summary Heap dumps are very helpful for memory analysis Memory Analyzer offers rich analysis feature set The analysis can often be automated
  • 32. 32 Questions and answers Memory Analyzer homepage @ Eclipse • http://www.eclipse.org/mat/ • Binary downloads • Source downloads • Forum • Getting started guide • Frequently asked questions • Bug reports
  • 33. 33 Thank you Andrew Johnson • IBM United Kingdom Limited Memory Analyzer homepage @ Eclipse • http://www.eclipse.org/mat/ IBM Support Assistant • http://www-01.ibm.com/software/support/isa/ • IBM Monitoring and Diagnostic Tools – Memory Analyzer