MemoryProfilingConfig


@RequiresApi(value = 29)
@ExperimentalBenchmarkConfigApi
class MemoryProfilingConfig


Configuration for memory heap profiling during macrobenchmark execution.

Enables Perfetto heapprofd data source to sample memory allocations in target applications on Android Q (API 29)+.

When MemoryProfilingConfig is provided in ExperimentalConfig, memory profiling runs during an additional benchmark pass after all regular measurement iterations complete. Regular measurement iterations are not profiled to avoid measurement overhead and memory footprint distortion.

The recorded trace from the memory profiling pass is saved with a -memoryProfiling suffix (e.g. ${uniqueName}_iter000-memoryProfiling.perfetto-trace) and contains embedded pprof profile data. Traces can be viewed directly in Perfetto UI or converted to standard pprof format using the Perfetto traceconv tool.

For more details, see:

Summary

Public constructors

MemoryProfilingConfig(
    isSampleArtHeapEnabled: Boolean,
    isSampleNativeHeapEnabled: Boolean
)

Public properties

Boolean

Set to true to sample ART Java/Kotlin heap allocations (com.android.art), tracking object allocations made by the Android Runtime.

Boolean

Set to true to sample native heap allocations (libc.malloc), tracking C/C++ memory allocations (e.g. malloc, calloc, new) made by native libraries.

Public constructors

MemoryProfilingConfig

Added in 1.6.0-alpha01
MemoryProfilingConfig(
    isSampleArtHeapEnabled: Boolean,
    isSampleNativeHeapEnabled: Boolean
)

Public properties

isSampleArtHeapEnabled

Added in 1.6.0-alpha01
val isSampleArtHeapEnabled: Boolean

Set to true to sample ART Java/Kotlin heap allocations (com.android.art), tracking object allocations made by the Android Runtime.

For details on ART heap profiling, see Perfetto ART Allocation Profiling.

isSampleNativeHeapEnabled

Added in 1.6.0-alpha01
val isSampleNativeHeapEnabled: Boolean

Set to true to sample native heap allocations (libc.malloc), tracking C/C++ memory allocations (e.g. malloc, calloc, new) made by native libraries.

For details on native heap profiling, see Perfetto Native Heap Profiler.