Deep dive into Heap Dump analysis Yannick Poireault

  • Slides: 18
Download presentation
Deep dive into Heap Dump analysis Yannick Poireault | Enterprise Support Engineer © 2018

Deep dive into Heap Dump analysis Yannick Poireault | Enterprise Support Engineer © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Agenda What problem are we addressing? Basic memory concepts Acquire a Heap dump Analyzing

Agenda What problem are we addressing? Basic memory concepts Acquire a Heap dump Analyzing Heap dump General tips Q&A © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Basics on Heap dump – The problem / the solution In Java, process of

Basics on Heap dump – The problem / the solution In Java, process of deallocating memory is handled automatically by the garbage collector Unit and integration tests can hardly simulate real life conditions: • long running application • high volume of data Cache optimization techniques … can cause high memory usage and slow down or crash the application ! KEY TAKEAWAY : Heap dumps are useful when troubleshooting Out Of Memory problems. © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Basics on Heap dump – Different Out Of Memory errors java. lang. Out. Of.

Basics on Heap dump – Different Out Of Memory errors java. lang. Out. Of. Memory. Error: Out of swap space java. lang. Out. Of. Memory. Error: Compressed class space java. lang. Out. Of. Memory. Error: reason Not applicable stack_trace_with_native_method java. lang. Out. Of. Memory. Error: Perm. Gen space java. lang. Out. Of. Memory. Error: Metaspace java. lang. Out. Of. Memory. Error: Java heap space java. lang. Out. Of. Memory. Error: GC Overhead limit exceeded © 2018 Adobe. All Rights Reserved. Adobe Confidential. May be investigated with analysis Perfect use-case for analysis

Basics on Heap dump – What are Heap dump? Binary snapshot of all the

Basics on Heap dump – What are Heap dump? Binary snapshot of all the object instances that are in memory Suitable for production with no overhead impact Has a wide platform coverage • Oracle JVM • IBM J 9 What does it contain? • Class-loader related data • Java objects data: classes, fields references and primitive values • Usually includes a full thread dump © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Acquire a Heap Dump – Use-case scenario Manual generation Automatic generation To benchmark or

Acquire a Heap Dump – Use-case scenario Manual generation Automatic generation To benchmark or validate a process Post-mortem analysis Triggered on-demand Automatic on out of memory Early stage of development During production jmap -dump: format=b, file=/path/bin. hprof pid -XX: +Heap. Dump. On. Out. Of. Memory. Error Jcmd, Visual. VM, Jprofiler, AEM, … -XX: Heap. Dump. Path © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Analyzing a Heap Dump – The tools Eclipse MAT – Memory Analyzer Tool •

Analyzing a Heap Dump – The tools Eclipse MAT – Memory Analyzer Tool • http: //www. eclipse. org/mat IBM Heap. Analyzer • https: //www. ibm. com/developerworks/community/heapanalyzer Oracle Visual. VM • https: //visualvm. github. io/index. html Oracle JHAT – Java Heap Analysis Tool • https: //docs. oracle. com/javase/7/docs/technotes/tools/share/jhat. html © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Analyzing a Heap Dump – The Overview © 2018 Adobe. All Rights Reserved. Adobe

Analyzing a Heap Dump – The Overview © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Analyzing a Heap Dump – Shallow Heap & Retained heap The shallow size of

Analyzing a Heap Dump – Shallow Heap & Retained heap The shallow size of an object is the sum of all its attributes size The retained size of an object is the sum of the shallow size of all objects it is keeping alive The retained heap can be calculated in two different ways © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Analyzing a Heap Dump – Unreachable Objects Histogram § An object is reachable if

Analyzing a Heap Dump – Unreachable Objects Histogram § An object is reachable if there exist a path of reference from the GC Roots by which the executing program can access it § Unreachable objects are eligible for garbage collection and will be finalized before freeing the memory § Finalization process is single threaded. Overriding the finalizer method in business objects is not recommended to avoid queuing § Verify the number of objects in the histogram and how much memory they are consuming © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Analyzing a Heap Dump – Leak suspects © 2018 Adobe. All Rights Reserved. Adobe

Analyzing a Heap Dump – Leak suspects © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Analyzing a Heap Dump – Histogram § Statistical view of instances number and their

Analyzing a Heap Dump – Histogram § Statistical view of instances number and their retained memory § Group by package to organize and inspect your business class § Filter the view using a regexp pattern § Inspect object attributes and drill-down into their references § Compare to another heap dump to monitor the evolution © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Analyzing a Heap Dump – Dominator tree Model the objects dependencies using a graph

Analyzing a Heap Dump – Dominator tree Model the objects dependencies using a graph The retained set for each object is calculated Object are sorted based on their retained set size The Leak suspects report leverage the Dominator tree Analyze the leak suspect and accumulation point © 2018 Adobe. All Rights Reserved. Adobe Confidential.

General tips – Inspect objects © 2018 Adobe. All Rights Reserved. Adobe Confidential.

General tips – Inspect objects © 2018 Adobe. All Rights Reserved. Adobe Confidential.

General tips – Object Query Language Similar syntax as SQL: use objects as table,

General tips – Object Query Language Similar syntax as SQL: use objects as table, and attributes as columns Results of the query can be exported to CSV List information (session ID and principal) for all Oak sessions • SELECT s. session. Id. to. String(), s. auth. Info. user. ID. to. S tring() FROM org. apache. jackrabbit. oak. jcr. session. Session Stats s List all authenticated users • SELECT u. id. to. String() FROM org. apache. jackrabbit. oak. security. user. User. I mpl u © 2018 Adobe. All Rights Reserved. Adobe Confidential.

General tips – Share with Customer Care Generates a Zip archive of the executed

General tips – Share with Customer Care Generates a Zip archive of the executed report. Add at least the Leak Suspects report. Keep the binary heap dump file in any case ! © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Thank You ! © 2018 Adobe. All Rights Reserved. Adobe Confidential.

Thank You ! © 2018 Adobe. All Rights Reserved. Adobe Confidential.