[BGOUG] Memory analyzer

2,036 views

Published on

A short introduction of Eclipse Memory analyzer and its basic features.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,036
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
45
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

[BGOUG] Memory analyzer

  1. 1. Eclipse Memory AnalyzerKrasimir SemerdzhievDevelopment Architect / SAP Labs Bulgaria
  2. 2. AgendaGetting startedGet hands dirtyQ&A© 2011 SAP AG. All rights reserved. 2
  3. 3. Getting startedFew assumptionsYou’ve passed beyond “Hello World” in JavaHello World apps tend not to require too much memoryYou’ve gotten an OutOfMemoryError at least once in your life :)You’re proficient already with Garbage CollectionAttended the previous BGOUG event GC session© 2011 SAP AG. All rights reserved. 3
  4. 4. Getting startedMemory analyzer basicsWorks with heap dumps – live snapshots of:© 2011 SAP AG. All rights reserved. 4
  5. 5. Getting startedHow to get a heap dumpNon-Interactive-XX:+HeapDumpOnOutOfMemoryErrorOn DemandJDK1.4.2_12+ and -XX:+HeapDumpOnCtrlBreakJDK6 and JConsole or VisualVMOn IBM VMs -Xdump:system:events=throw,filter=java/lang/OutOfMemoryError, request=exclusive+prepwalkMore…http://wiki.eclipse.org/index.php/MemoryAnalyzer#Getting_a_Heap_Dump© 2011 SAP AG. All rights reserved. 5
  6. 6. Getting startedShallow vs. Retained heapShallow heap is the memory consumed by one objectRetained set of X is the set of objects that will be garbage collected if X is garbagecollectedRetained heap of X is the sum of shallow sizes of all objects in the retained set ofX, 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. 7. Getting startedDominator treeAn 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. 8. Getting startedDominator tree© 2011 SAP AG. All rights reserved. 8
  9. 9. Getting startedJava references – java.lang.ref Softly reachable Created Initialized Strongly reachable Finalized Weakly reachableSoft reference Phantom reachableGC will try to preserve the objectWill collect it prior to throwing OutOfMemoryErrorWeak referenceGC is free to reclaim the object.Phantom referenceTrack object collections© 2011 SAP AG. All rights reserved. 9
  10. 10. Getting startedGC roots in JavaKeeps 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. 11. Getting startedWhat is a leak?© 2011 SAP AG. All rights reserved. 11
  12. 12. AgendaGetting startedGet hands dirtyQ&A© 2011 SAP AG. All rights reserved. 12
  13. 13. Analyze memory consumptionGetting the heap dump: SetupJConsole refuses to connect© 2011 SAP AG. All rights reserved. 13
  14. 14. Analyze memory consumptionDEMO© 2011 SAP AG. All rights reserved. 14
  15. 15. How to get involved?Eclipse Home Page http://www.eclipse.org/mat/Forum eclipse.technology.memory-analyzerBlog http://dev.eclipse.org/blogs/memoryanalyzer© 2011 SAP AG. All rights reserved. 15
  16. 16. Questions?Krasimir Semerdzhievkrasimir.semerdzhiev@sap.com
  17. 17. Thank You!Krasimir Semerdzhievkrasimir.semerdzhiev@sap.com

×