main

square/leakcanary

Last updated at: 29/12/2023 09:37

AndroidDebugHeapDumper.kt

TLDR

This file defines the AndroidDebugHeapDumper object, which implements the HeapDumper interface. It provides a method to dump the Android heap using Debug.dumpHprofData.

Classes

AndroidDebugHeapDumper

This class defines the AndroidDebugHeapDumper object, which implements the HeapDumper interface. It provides a method dumpHeap to dump the Android heap by calling Debug.dumpHprofData.

package leakcanary

import android.os.Debug
import java.io.File

/**
 * Dumps the Android heap using [Debug.dumpHprofData].
 *
 * Note: despite being part of the Debug class, [Debug.dumpHprofData] can be called from non
 * debuggable non profileable builds.
 */
object AndroidDebugHeapDumper : HeapDumper {
  override fun dumpHeap(heapDumpFile: File) {
    Debug.dumpHprofData(heapDumpFile.absolutePath)
  }
}