• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download

<lambda>null1 package shark
2 
3 /**
4  * Finds the objects that are leaking by scanning all objects in the heap dump
5  * and delegating the decision to a list of [FilteringLeakingObjectFinder.LeakingObjectFilter]
6  */
7 class FilteringLeakingObjectFinder(private val filters: List<LeakingObjectFilter>) :
8   LeakingObjectFinder {
9 
10   /**
11    * Filter to be passed to the [FilteringLeakingObjectFinder] constructor.
12    */
13   fun interface LeakingObjectFilter {
14     /**
15      * Returns whether the passed in [heapObject] is leaking. This should only return true
16      * when we're 100% sure the passed in [heapObject] should not be in memory anymore.
17      */
18     fun isLeakingObject(heapObject: HeapObject): Boolean
19   }
20 
21   override fun findLeakingObjectIds(graph: HeapGraph): Set<Long> {
22     return graph.objects
23       .filter { heapObject ->
24         filters.any { filter ->
25           filter.isLeakingObject(heapObject)
26         }
27       }
28       .map { it.objectId }
29       .toSet()
30   }
31 }
32