# MemoryProfilingConfig

Artifact: [androidx.benchmark:benchmark-common](https://developer.android.com/jetpack/androidx/releases/benchmark) [View Source](https://cs.android.com/search?q=file:androidx/benchmark/ExperimentalBenchmarkConfigApi.kt+class:androidx.benchmark.MemoryProfilingConfig) Added in [1.6.0-alpha01](https://developer.android.com/jetpack/androidx/releases/benchmark#1.6.0-alpha01)

*** ** * ** ***


```
@RequiresApi(value = 29)
@ExperimentalBenchmarkConfigApi
class MemoryProfilingConfig
```

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/kotlin/androidx/benchmark/MemoryProfilingConfig` is provided in `https://developer.android.com/reference/kotlin/androidx/benchmark/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](https://ui.perfetto.dev/) or converted to standard `pprof` format using the Perfetto [traceconv tool](https://perfetto.dev/docs/analysis/traceconv).

For more details, see:

- [Perfetto ART Allocation Profiling](https://perfetto.dev/docs/data-sources/native-heap-profiler#art-allocation-profiling)

- [Perfetto Native Heap Profiler](https://perfetto.dev/docs/data-sources/native-heap-profiler)

- [Perfetto Traceconv Tool](https://perfetto.dev/docs/analysis/traceconv)

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/benchmark/MemoryProfilingConfig#MemoryProfilingConfig(kotlin.Boolean,kotlin.Boolean)( isSampleArtHeapEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, isSampleNativeHeapEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/benchmark/MemoryProfilingConfig#isSampleArtHeapEnabled()` Set to true to sample ART Java/Kotlin heap allocations (`com.android.art`), tracking object allocations made by the Android Runtime. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/benchmark/MemoryProfilingConfig#isSampleNativeHeapEnabled()` 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](https://developer.android.com/jetpack/androidx/releases/benchmark#1.6.0-alpha01)

```
MemoryProfilingConfig(
    isSampleArtHeapEnabled: Boolean,
    isSampleNativeHeapEnabled: Boolean
)
```

## Public properties

### isSampleArtHeapEnabled

Added in [1.6.0-alpha01](https://developer.android.com/jetpack/androidx/releases/benchmark#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](https://perfetto.dev/docs/data-sources/native-heap-profiler#art-allocation-profiling).

### isSampleNativeHeapEnabled

Added in [1.6.0-alpha01](https://developer.android.com/jetpack/androidx/releases/benchmark#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](https://perfetto.dev/docs/data-sources/native-heap-profiler).