package Ġsh ark Ċ Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Temporary Folder Ċ import Ġsh ark . Filtering Le aking Object Finder . Le aking Object Filter Ċ import Ġsh ark . internal . Open J dk Instance Ref Read ers . LINK ED _ LIST Ċ import Ġjava . io . File Ċ import Ġjava . util . LinkedList Ċ import Ġjava . util . concurrent . Concurrent HashMap Ċ import Ġjava . util . concurrent . Copy On Write ArrayList Ċ import Ġsh ark . internal . Ch aining Instance Reference Reader . Virtual Instance Reference Reader . Optional Factory Ċ import Ġsh ark . H prof Heap Graph . Companion . open Heap Graph Ċ import Ġsh ark . internal . Ch aining Instance Reference Reader Ċ import Ġsh ark . internal . Class Reference Reader Ċ import Ġsh ark . internal . Delegating Object Reference Reader Ċ import Ġsh ark . internal . Field Instance Reference Reader Ċ import Ġsh ark . internal . Java Local Reference Reader Ċ import Ġsh ark . internal . Object Array Reference Reader Ċ import Ġsh ark . internal . Open J dk Instance Ref Read ers Ċ Ċ class ĠOpen J dk Instance Ref Read ers Test Ġ{ ĊĊĠ Ġclass ĠRet ained ĊĠ Ġclass ĠSome Key ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġ@ Jvm Static ĊĠĠĠ Ġvar Ġleak Root : ĠAny ? Ġ= Ġnull ĊĠ Ġ} ĊĊĠ Ġ@ get : Rule ĊĠ Ġval Ġtest Folder Ġ= ĠTemporary Folder () ĊĊĠ Ġ@ After Ġfun ĠtearDown () Ġ{ ĊĠĠĠ Ġleak Root Ġ= Ġnull ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` LinkedList Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġlist Ġ= ĠLinkedList < Any >() ĊĠĠĠ Ġlist Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġlist ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( LINK ED _ LIST ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( LinkedList :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ 0 ]") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` LinkedList Ġno Ġexpand er `() Ġ{ ĊĠĠĠ Ġval Ġlist Ġ= ĠLinkedList < Any >() ĊĠĠĠ Ġlist Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġlist ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak Ġ{ Ġnull Ġ} ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 2 ) ĊĊĠĠĠ Ġwith ( ref Path [ 0 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( LinkedList :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" first ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 1 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . util . LinkedList \$ Node ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" item ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` LinkedList Ġretained Ġsize Ġis Ġidentical Ġwhether Ġexpand ing Ġor Ġnot `() Ġ{ ĊĠĠĠ Ġval Ġlist Ġ= ĠLinkedList < Any >() ĊĠĠĠ Ġlist Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġlist ĊĊĠĠĠ Ġval Ġh prof File Ġ= Ġdump Heap () ĊĊĠĠĠ Ġval Ġretained Size Expanded Ġ= Ġh prof File . find Path From Leak ( ĊĠĠĠĠĠ Ġcompute Ret ained Heap Size Ġ= Ġtrue , ĊĠĠĠĠĠ Ġvirtual Ref Reader Factory Ġ= ĠLINK ED _ LIST ĊĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ. first () ĊĠĠĠĠĠ Ġ. origin Object ĊĠĠĠĠĠ Ġ. ret ained Heap Byte Size ĊĊĠĠĠ Ġval Ġretained Size Not Expanded Ġ= Ġh prof File . find Path From Leak ( ĊĠĠĠĠĠ Ġcompute Ret ained Heap Size Ġ= Ġtrue , ĊĠĠĠĠĠ Ġvirtual Ref Reader Factory Ġ= Ġ{ Ġnull Ġ} ĊĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ. first () ĊĠĠĠĠĠ Ġ. origin Object ĊĠĠĠĠĠ Ġ. ret ained Heap Byte Size ĊĊĠĠĠ ĠassertThat ( ret ained Size Expanded ). isEqualTo ( ret ained Size Not Expanded ) ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` ArrayList Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġlist Ġ= ĠArrayList < Any >() ĊĠĠĠ Ġlist Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġlist ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . ARRAY _ LIST ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( ArrayList :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ 0 ]") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` ArrayList Ġno Ġexpand er `() Ġ{ ĊĠĠĠ Ġval Ġlist Ġ= ĠArrayList < Any >() ĊĠĠĠ Ġlist Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġlist ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak Ġ{ Ġnull Ġ} ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 2 ) ĊĊĠĠĠ Ġwith ( ref Path [ 0 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( ArrayList :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" element Data ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 1 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . lang . Object [] ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ 0 ]") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` Copy On Write ArrayList Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġlist Ġ= ĠCopy On Write ArrayList < Any >() ĊĠĠĠ Ġlist Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġlist ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . COPY _ ON _ WRITE _ ARRAY _ LIST ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( Copy On Write ArrayList :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ 0 ]") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` Copy On Write ArrayList Ġno Ġexpand er `() Ġ{ ĊĠĠĠ Ġval Ġlist Ġ= ĠCopy On Write ArrayList < Any >() ĊĠĠĠ Ġlist Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġlist ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak Ġ{ Ġnull Ġ} ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 2 ) ĊĊĠĠĠ Ġwith ( ref Path [ 0 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( Copy On Write ArrayList :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" array ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 1 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . lang . Object [] ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ 0 ]") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` HashMap Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠHashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [ Some Key ()] Ġ= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . HASH _ MAP ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( HashMap :: class . qualified Name ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` HashMap Ġkey Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠHashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [ Ret ained ()] Ġ= Ġ" value " ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . HASH _ MAP ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( HashMap :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ key ()] ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` Linked HashMap Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠLinkedHashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [ Some Key ()] Ġ= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . HASH _ MAP ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( Linked HashMap :: class . qualified Name ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` Concurrent HashMap Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠConcurrent HashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [ Some Key ()] Ġ= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . CON CURRENT _ HASH _ MAP ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( Concurrent HashMap :: class . qualified Name ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` Concurrent HashMap Ġkey Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠConcurrent HashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [ Ret ained ()] Ġ= Ġ" value " ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . CON CURRENT _ HASH _ MAP ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( Concurrent HashMap :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ key ()] ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` Concurrent HashMap Ġno Ġexpand er `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠConcurrent HashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [ Some Key ()] Ġ= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak Ġ{ Ġnull Ġ} ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 3 ) ĊĊĠĠĠ Ġwith ( ref Path [ 0 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( Concurrent HashMap :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" table ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 1 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . util . concurrent . Concurrent HashMap \$ Node [] ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ 0 ]") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 2 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . util . concurrent . Concurrent HashMap \$ Node ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" val ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` HashMap Ġno Ġexpand er `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠHashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [ Some Key ()] Ġ= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak Ġ{ Ġnull Ġ} ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 3 ) ĊĊĠĠĠ Ġwith ( ref Path [ 0 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( HashMap :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" table ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 1 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . util . HashMap \$ Node [] ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ 0 ]") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 2 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . util . HashMap \$ Node ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" value ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` HashMap Ġexpanded Ġwith Ġnon Ġstring Ġkey `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠHashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [ Some Key ()] Ġ= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . HASH _ MAP ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). matches ("\\ [ instance Ġ@ \\ d * Ġof Ġsh ark \\. Open J dk Instance Ref Read ers Test \\\ $ Some Key ]") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` HashMap Ġexpanded Ġwith Ġstring Ġkey `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠHashMap < Any , ĠAny >() ĊĠĠĠ Ġmap [" String Key "] Ġ= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġmap ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . HASH _ MAP ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ \" String Key \"] ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` HashSet Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġset Ġ= ĠHashSet < Any >() ĊĠĠĠ Ġset Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġset ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . HASH _ SET ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( HashSet :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ element ()] ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` Linked HashSet Ġexpanded `() Ġ{ ĊĠĠĠ Ġval Ġset Ġ= ĠLinked HashSet < Any >() ĊĠĠĠ Ġset Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġset ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak ( Open J dk Instance Ref Read ers . HASH _ SET ) ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 1 ) ĊĊĠĠĠ Ġwith ( ref Path . first ()) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( Linked HashSet :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ element ()] ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` HashSet Ġno Ġexpand er `() Ġ{ ĊĠĠĠ Ġval Ġset Ġ= ĠHashSet < Any >() ĊĠĠĠ Ġset Ġ+= ĠRet ained () ĊĠĠĠ Ġleak Root Ġ= Ġset ĊĊĠĠĠ Ġval Ġref Path Ġ= Ġfind Leak Ġ{ Ġnull Ġ} ĊĊĠĠĠ ĠassertThat ( ref Path ). has Size ( 4 ) ĊĊĠĠĠ Ġwith ( ref Path [ 0 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( HashSet :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" map ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 1 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo ( HashMap :: class . qualified Name ) ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" table ") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 2 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . util . HashMap \$ Node [] ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo ("[ 0 ]") ĊĠĠĠ Ġ} ĊĠĠĠ Ġwith ( ref Path [ 3 ]) Ġ{ ĊĠĠĠĠĠ ĠassertThat ( own ing ClassName ). isEqualTo (" java . util . HashMap \$ Node ") ĊĠĠĠĠĠ ĠassertThat ( reference DisplayName ). isEqualTo (" key ") ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġfind Leak ( expand er Factory : ĠOptional Factory ): ĠList < Leak Trace Reference > Ġ{ ĊĠĠĠ Ġval Ġh prof File Ġ= Ġdump Heap () ĊĠĠĠ Ġreturn Ġh prof File . find Path From Leak ( compute Ret ained Heap Size Ġ= Ġfalse , Ġexpand er Factory ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠFile . find Path From Leak ( ĊĠĠĠ Ġcompute Ret ained Heap Size : ĠBoolean , ĊĠĠĠ Ġvirtual Ref Reader Factory : ĠOptional Factory , ĊĠ Ġ): ĠList < Leak Trace Reference > Ġ{ ĊĠĠĠ Ġval Ġheap Analyzer Ġ= ĠHeap Analyzer ( On Analysis Progress Listener . NO _ OP ) ĊĊĠĠĠ Ġval Ġanalysis Ġ= Ġopen Heap Graph (). use Ġ{ Ġgraph Ġ-> ĊĠĠĠĠĠ Ġval Ġreference Matchers Ġ= Ġdefault Reference Matchers ĊĊĠĠĠĠĠ Ġval Ġvirtual Ref Read ers Ġ= Ġvirtual Ref Reader Factory . create ( graph )?. let Ġ{ ĊĠĠĠĠĠĠĠ ĠlistOf ( it ) ĊĠĠĠĠĠ Ġ} Ġ?: Ġempty List () ĊĊĠĠĠĠĠ Ġval Ġinstance Expand er Ġ= ĠCh aining Instance Reference Reader ( ĊĠĠĠĠĠĠĠ Ġvirtual Ref Read ers Ġ= Ġvirtual Ref Read ers Ġ+ ĠJava Local Reference Reader ( graph , Ġreference Matchers ), ĊĠĠĠĠĠĠĠ Ġfield Ref Reader Ġ= ĠField Instance Reference Reader ( graph , Ġreference Matchers ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġreference Reader Ġ= ĠDeleg ating Object Reference Reader ( ĊĠĠĠĠĠĠĠ Ġclass Reference Reader Ġ= ĠClass Reference Reader ( graph , Ġreference Matchers ), ĊĠĠĠĠĠĠĠ Ġinstance Reference Reader Ġ= Ġinstance Expand er , ĊĠĠĠĠĠĠĠ Ġobject Array Reference Reader Ġ= ĠObject Array Reference Reader () ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġheap Analyzer . analyze ( ĊĠĠĠĠĠĠĠ Ġheap Dump File Ġ= Ġthis , ĊĠĠĠĠĠĠĠ Ġgraph Ġ= Ġgraph , ĊĠĠĠĠĠĠĠ Ġle aking Object Finder Ġ= ĠFiltering Le aking Object Finder ( listOf ( object Ġ: ĊĠĠĠĠĠĠĠĠĠ ĠLe aking Object Filter Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġis Le aking Object ( heap Object : ĠHeap Object ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġheap Object . as Instance ?. instance Of ( Ret ained :: class ) Ġ?: Ġfalse ĊĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ})), ĊĠĠĠĠĠĠĠ Ġreference Matchers Ġ= Ġreference Matchers , ĊĠĠĠĠĠĠĠ Ġcompute Ret ained Heap Size Ġ= Ġcompute Ret ained Heap Size , ĊĠĠĠĠĠĠĠ Ġobject Inspect ors Ġ= Ġempty List (), ĊĠĠĠĠĠĠĠ Ġmetadata Extractor Ġ= ĠMetadata Extractor . NO _ OP , ĊĠĠĠĠĠĠĠ Ġreference Reader Ġ= Ġreference Reader ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ}. apply Ġ{ ĊĠĠĠĠĠ Ġif Ġ( this Ġis ĠHeap Analysis Failure ) Ġ{ ĊĠĠĠĠĠĠĠ Ġprintln ( this ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ġas ĠHeap Analysis Success ĊĠĠĠ Ġval Ġleak Trace Ġ= Ġanalysis . application Le aks [ 0 ]. leak Tr aces . first () ĊĠĠĠ Ġprintln ( leak Trace . to Simple Path String ()) ĊĠĠĠ Ġval Ġindex Ġ= Ġleak Trace . reference Path . indexOf First Ġ{ Ġit . reference Name Ġ== Ġ:: leak Root . name Ġ} ĊĠĠĠ Ġval Ġref From Expanded Type Index Ġ= Ġindex Ġ+ Ġ 1 ĊĠĠĠ Ġreturn Ġleak Trace . reference Path . sub List ( ref From Expanded Type Index , Ġleak Trace . reference Path . size ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġdump Heap (): ĠFile Ġ{ ĊĠĠĠ Ġval Ġh prof Folder Ġ= Ġtest Folder . new Folder () ĊĠĠĠ Ġval Ġh prof File Ġ= ĠFile ( h prof Folder , Ġ" jvm _ heap . h prof ") ĊĠĠĠ ĠJ vm Test Heap Dump er . dump Heap ( h prof File . absolute Path ) ĊĠĠĠ Ġreturn Ġh prof File ĊĠ Ġ} Ċ } Ċ