sap memory analyzer...basic steps and features walk-through ... objects or sizes > 2 gb. once...
TRANSCRIPT
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 1
Welcome to the SAP Memory Analyzer
SAP Memory Analyzer: Basic Steps and Features Walk-through
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 2
Basic Steps with SAP Memory Analyzer
IOIOIIIOIIOIOIOIOIIOIIOI
(1) Get Heap Dump
(2) Parse Heap Dump
(3) Analyze Heap Dump
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 3
(1) Get Heap Dump
t
IOIOIIIOIIOIOIOIOIIOIIOI
Available for which JDKs?
• Sun, SAP and HP JDK• >= 1.4.2_12 and >= 1.5.0_7
Therefore applies to SAP:
• 640, 04s, 710, CE …• Windows, Solaris, HP-UX
HPROF Binary Heap Dump
Heap dump contains a snapshot of all objects that are alive at one point in time.
All ObjectsClass, fields, primitive values and
references
All ClassesClassLoader, name, super class, static
fields
All ClassLoadersDefined classes
Garbage Collection RootsObjects defined to be reachable by the JVM
IBM JDK has its own proprietary format.
You need to use IBM’s own tools.
How to get an heap dump?
• On Out Of Memory-XX:+HeapDumpOnOutOfMemoryError
• On Ctrl-Break-XX:+HeapDumpOnCtrlBreak
• AGENT LIB• JMAP• JCONSOLE• JVMMON
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 4
(2) Parse Heap Dump
t
IOIOIIIOIIOIOIOIOIIOIIOI
SAP Memory Analyzer parses heap dumps on first open. Preprocessing allows faster analysis on smaller machines.
64 bit machines only needed for dumps with > 20 million objects or sizes > 2 GB.
Once parsed, analyze the dump on 32 bit developer machines – it opens instantly.
A1SSize: S
98.000.000Objects
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 5
(3) Analyze Heap Dump
t
IOIOIIIOIIOIOIOIOIIOIIOI
Get an Overview
• total number of objects
• total heap size• class histogram
Identify HolderCheck ContentFind Big Chunks
Get Heap Dump
Parse Heap Dump
Analyze Heap Dump
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 6
(3) Analyze Heap Dump – Get an Overview
t
IOIOIIIOIIOIOIOIOIIOIIOI
Get an Overview
• total number of objects
• total heap size• class histogram
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 7
Snapshot Info and Class Histogram
Number of objects
Number of classes
Number of class loaders
The histogram lists per class the number of objects and their total shallow size. Anything but char[] is usually suspicious.
Total heap sizeLook out for accumulation of classes from the same package.
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 8
Class Histogram Grouping
Group classes by class loader
SAP Memory Analyzer extracts the names of the deployment units
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 9
(3) Analyze Heap Dump – Find Big Chunks
t
IOIOIIIOIIOIOIOIOIIOIIOI
Get an Overview
• total number of objects
• total heap size• class histogram
Find Big Chunks
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 10
Find Big Single Objects
Open the Dominator Treeto see the biggest distinct single objects Retained size = memory
freed if this object would be garbage collected
See Object Inspector for object details and field values.
This one HashMap keeps ~160MB alive, which are 6% of the total heap!
Look out for instances of the same class! Even better: group by classes (see next slide).
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 11
Find Big Groups of Objects
Group by classes to find big chunks kept alive by instances of one class
398 instances retain ~430MB, i.e. 15%!
4 classes in the .*sushi.*and .*sashimi.* packages consume 1.1 GB, i.e. 40%!
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 12
(3) Analyze Heap Dump – Check Content
t
IOIOIIIOIIOIOIOIOIIOIIOI
Get an Overview
• total number of objects
• total heap size• class histogram
Check ContentFind Big Chunks
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 13
Looking Into Big Memory Chunks
Drill down in the dominator tree: What is kept alive by the objects?
Using the context menu to show the histogram of the retained set, i.e. all objects kept alive grouped by classes.
Check outbound references to understand the data structures.
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 14
(3) Analyze Heap Dump – Identify Holder
t
IOIOIIIOIIOIOIOIOIIOIIOI
Get an Overview
• total number of objects
• total heap size• class histogram
Identify HolderCheck ContentFind Big Chunks
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 15
Paths From GC Roots
The orange dot indicates a garbage collection root.
At the end of the line you see the reason, e.g. it could have been used as local variable.
For all GC Roots associated with a thread (Local Variable, Busy Monitor, JNI Local), we also show the thread.
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 16
(3) Analyze Heap Dump
t
IOIOIIIOIIOIOIOIOIIOIIOI
Get an Overview
• total number of objects
• total heap size• class histogram
Identify HolderCheck ContentFind Big Chunks
Get Heap Dump
Parse Heap Dump
Analyze Heap Dump
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 17
Advanced Features
Execute SQL-like queries on the objects in the heap dump with the build-in OQL.
Use the console to run special purpose queries implemented in commands.
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 18
SAP NetWeaver FeaturesSAP Memory Analyzer extracts 640, NW04s and 710 sessions and displays domains, ids and size in one view.
The Cache view shows the content of all cache regions.
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 19
Groups of objectsFinding big chunks of memory
– Grouping in Dominator Tree– TOP_CONSUMERS– ARR_SZ_HISTOGRAM– LOCAL_VARS– OQL
Content Analysis– Object lists/histograms– Analyze the retained set– Class-level outbound references– OQL
Holder Analysis– Class-level inbound references– Multiple paths from the GC roots– Immediate Dominators
Single objectFinding big chunks of memory
– Check the Dominator Tree– TOP_CONSUMERS
Content Analysis– Expand/explore the Dominator Tree– Analyze the retained set– Object outbound references/Object inspector– OQL
Holder Analysis– Object inbound references– Paths from the GC roots
Feature Overview
Overview– Total heap size– Total number of objects/classes– Class histogram– Histogram by ClassLoader
© SAP AG 2007, Memory Analysis with SAP Memory Analyzer / 20
Resources
SAP SDN Wiki
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/Java/Java+Memory+Analysis