Contenu connexe
Similaire à [BGOUG] Memory analyzer (20)
Plus de SAP HANA Cloud Platform (14)
[BGOUG] Memory analyzer
- 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
- 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
- 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
- 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