xref: /aosp_15_r20/external/leakcanary2/shark/src/main/java/shark/LeakingObjectFinder.kt (revision d9e8da70d8c9df9a41d7848ae506fb3115cae6e6)

<lambda>null1 package shark
2 
3 /**
4  * Finds the objects that are leaking, for which Shark will compute
5  * leak traces.
6  *
7  * This is a functional interface with which you can create a [LeakingObjectFinder] from a lambda.
8  */
9 fun interface LeakingObjectFinder {
10 
11   /**
12    * For a given heap graph, returns a set of object ids for the objects that are leaking.
13    */
14   fun findLeakingObjectIds(graph: HeapGraph): Set<Long>
15 
16   companion object {
17     /**
18      * Utility function to create a [LeakingObjectFinder] from the passed in [block] lambda
19      * instead of using the anonymous `object : LeakingObjectFinder` syntax.
20      *
21      * Usage:
22      *
23      * ```kotlin
24      * val listener = LeakingObjectFinder {
25      *
26      * }
27      * ```
28      */
29     inline operator fun invoke(crossinline block: (HeapGraph) -> Set<Long>): LeakingObjectFinder =
30       LeakingObjectFinder { graph -> block(graph) }
31   }
32 }
33