# fuchsia.memory.heapdump.client

<br />

Added: 15

## **PROTOCOLS**

## Collector

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=213)*

Protocol to request and retrieve memory profiles.

<br />

### DownloadStoredSnapshot

Retrieves a stored snapshot.

#### Request

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#CollectorDownloadStoredSnapshotRequest` |

### ListStoredSnapshots

Retrieves the list of all the available stored snapshots.

#### Request

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#CollectorListStoredSnapshotsRequest` |

### TakeLiveSnapshot

Obtains a snapshot of the current live allocations in an instrumented process.

#### Request

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#CollectorTakeLiveSnapshotRequest` |

## SnapshotReceiver

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=164)*

Protocol to transmit snapshot(s) as a stream of elements.

<br />

### Batch

Delivers a batch of snapshot elements.

It will be called for each batch of elements, and finally with an empty
batch to indicate that all data has been sent.

If `multi_process` was set to true, two extra batches will be sent to
enclose each snapshot:

- A batch with exactly one SnapshotHeader at the beginning.
- An empty batch at the end.

#### Request

| Name | Type |
|---|---|
| `batch` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#SnapshotElement>` |

#### Response

\<EMPTY\>

### ReportError

Reports an error. No other batches or errors will follow.

#### Request

| Name | Type |
|---|---|
| `error` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#CollectorError` |

#### Response

\<EMPTY\>

## StoredSnapshotIterator

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=202)*

Protocol to retrieve a list of StoredSnapshots.

<br />

### GetNext

Retrieves the next batch of StoredSnapshots elements.

An empty response signals the end of the list.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#StoredSnapshotIterator_GetNext_Result` |

## **STRUCTS**

### BuildId

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=111)*

An ELF build ID.

<br />

| Field | Type | Description | Default |
|---|---|---|---|
| `value` | `vector<uint8>:32` |   | No default |

### StoredSnapshotIterator_GetNext_Response

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=206)*

| Field | Type | Description | Default |
|---|---|---|---|
| `batch` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#StoredSnapshot>` |   | No default |

## **ENUMS**

### CollectorError [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

Type: `uint32`

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=15)*

The reason why a method failed.

<br />

| Name | Value | Description |
|---|---|---|
| ### PROCESS_SELECTOR_UNSUPPORTED | `1` | The given ProcessSelector value is not supported. |
| ### PROCESS_SELECTOR_NO_MATCH | `2` | The given ProcessSelector value does not match any process. |
| ### PROCESS_SELECTOR_AMBIGUOUS | `3` | The given ProcessSelector value matches more than one process but the requested operation needs a unique match. |
| ### LIVE_SNAPSHOT_FAILED | `4` | Failed to take a live snapshot. |
| ### STORED_SNAPSHOT_NOT_FOUND | `5` | The requested StoredSnapshot does not exist. |

## **TABLES**

### Allocation

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=57)*

One or more allocated memory blocks.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `address` | `uint64` | Address of the memory block. |
| ### 2 | `size` | `uint64` | Total memory blocks size, in bytes. |
| ### 3 | `stack_trace_key` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#StackTraceKey` | Stack trace of the allocation site. |
| ### 4 | `timestamp` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#InstantMono` | Allocation timestamp. |
| ### 5 | `thread_info_key` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#ThreadInfoKey` | Allocating thread. |
| ### 6 | `count` | `uint64` | Number of allocated memory blocks that have been aggregated into this element. 1 by default. Added: 29 |

### BlockContents

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=144)*

The contents of an allocated memory block.

In order to avoid exceeding the channel's maximum message size, bigger blocks can be split in
chunks. Receivers should be prepared to handle multiple BlockContents with the same address and
reassemble them by concatenating their payloads. Each block's reassembled size always matches
the size field of the corresponding Allocation.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `address` | `uint64` | The address of the corresponding memory block. |
| ### 2 | `contents` | `vector<uint8>` | The payload. |

### CollectorDownloadStoredSnapshotRequest [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=253)*

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `snapshot_id` | `uint32` | The identifier of the snapshot to be downloaded. The list of the available snapshots can be retrieved with ListStoredSnapshots. Required. |
| ### 2 | `receiver` | `client_end:https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#SnapshotReceiver` | Where the elements of the requested snapshot will be sent to. Required. |

### CollectorListStoredSnapshotsRequest [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=242)*

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `iterator` | `server_end:https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#StoredSnapshotIterator` | The server_end of the StoredSnapshotIterator that will be used to retrieve the results. Required. |
| ### 2 | `process_selector` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#ProcessSelector` | If present, only retrieve snapshots that refer to matching processes. |

### CollectorTakeLiveSnapshotRequest [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=215)*

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `process_selector` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#ProcessSelector` | The instrumented process(es) to operate on. If not set, any process will be considered a match. |
| ### 2 | `receiver` | `client_end:https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#SnapshotReceiver` | Where the elements of the requested snapshot will be sent to. Required. |
| ### 3 | `with_contents` | `bool` | Whether the snapshot should include the contents of each memory block. If not set, false is assumed. |
| ### 4 | `multi_process` | `bool` | Whether this call is allowed to take a snapshot of more than one process and, therefore, return more than one snapshot. If not set, false is assumed. If set to true, each snapshot will be preceded by a SnapshotHeader. Added: HEAD |

### ExecutableRegion

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=116)*

A memory region containing code loaded from an ELF file.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `address` | `uint64` | The address of the memory region. |
| ### 2 | `size` | `uint64` | Region size, in bytes. |
| ### 3 | `file_offset` | `uint64` | The file offset corresponding to the first byte within the region. |
| ### 4 | `build_id` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#BuildId` | The build ID of the ELF file. |
| ### 5 | `vaddr` | `uint64` | The address of the memory region relative to the file's load address. Added: 27 |
| ### 6 | `name` | `string` | Description of the memory region (e.g. ELF soname or VMO name). Added: 27 |

### SnapshotHeader

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=48)*

Marks the beginning of a new snapshot.

Note: this element is only present in live snapshots taken with
`multi_process` set to true.
Added: HEAD

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `process_name` | `string:32` | ZX_PROP_NAME of the process the snapshot is about. |
| ### 2 | `process_koid` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Koid` | Koid of the process. |

### StackTrace

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=84)*

A stack trace.

In order to avoid exceeding the channel's maximum message size, stack traces can be split in
multiple chunks. Receivers should be prepared to handle multiple StackTrace elements with the
same key and reassemble them by concatenating their program addresses.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `stack_trace_key` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#StackTraceKey` | A number that uniquely identifies this stack trace within the parent snapshot. |
| ### 2 | `program_addresses` | `vector<uint64>` | The program counters corresponding to stack each frame. Entries are listed in reverse call order: the first entry refers to the leaf frame, and the last entry refers to the frame at the root of the call stack. |

### StoredSnapshot

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=187)*

A snapshot that is stored on the device and that can be downloaded.

Application-initiated snapshots belong to this category.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `snapshot_id` | `uint32` | A number that uniquely identifies this snapshot within a Collector. |
| ### 2 | `snapshot_name` | `string:32` | The name given to this snapshot. |
| ### 3 | `process_koid` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Koid` | The koid of the process that this snapshot refers to. |
| ### 4 | `process_name` | `string:32` | The name of the process that this snapshot refers to. |

### ThreadInfo

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=99)*

Information on a given thread.

Note: Under some circumstances, more than one entry could exist for a given koid (e.g. if the
thread changed its name between different allocations).

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `thread_info_key` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#ThreadInfoKey` | A number that uniquely identifies this entry within the parent snapshot. |
| ### 2 | `koid` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Koid` | The koid of the thread that this entry refers to. |
| ### 3 | `name` | `string:32` | The name of the thread that this entry refers to. |

## **UNIONS**

### ProcessSelector [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=34)*

Filter to restrict an operation to a subset of the available processes.

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `by_name` | `string:32` | Matches any process with the given ZX_PROP_NAME. |
| ### 2 | `by_koid` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Koid` | Matches the process with the given koid. ZX_KOID_KERNEL(1) stands for the kernel. |

<br />

### SnapshotElement [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=153)*

An element that is part of a snapshot.

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `allocation` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#Allocation` |   |
| ### 2 | `stack_trace` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#StackTrace` |   |
| ### 3 | `executable_region` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#ExecutableRegion` |   |
| ### 4 | `block_contents` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#BlockContents` |   |
| ### 5 | `thread_info` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#ThreadInfo` |   |
| ### 6 | `snapshot_header` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#SnapshotHeader` | Added: HEAD |

<br />

### StoredSnapshotIterator_GetNext_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.memory.heapdump.client/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=206)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#StoredSnapshotIterator_GetNext_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.memory.heapdump.client#CollectorError` |   |

<br />

## **CONSTANTS**

| Name | Value | Type | Description |
|---|---|---|---|
| [MAX_BUILD_ID_LENGTH](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=9) | `32` | `uint32` |   |

## **ALIASES**

| Name | Value | Description |
|---|---|---|
| [StackTraceKey](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=11) | `uint64` |   |
| [ThreadInfoKey](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.memory.heapdump.client/client.fidl;l=12) | `uint64` |   |