> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# Memory

This page documents the `Memory` CDP domain supported by Lynx DevTool.



:::warning Experimental reference
This generated reference is still being completed.

- CDP events are not included yet.
- Some Lynx extensions are listed but do not yet have detailed documentation.
- Method descriptions are not automatically verified against the implementation and may be incomplete or inaccurate.

Verify behavior against the implementation and the linked upstream CDP reference before relying on it.
:::

## Overview

- Scope: `global-and-instance`
- CDP domain: [Memory](https://chromedevtools.github.io/devtools-protocol/tot/Memory/)

## Lynx Extensions

### `Memory.getAllMemoryUsage`

Queries global Lynx-attributed memory usage across live registered Lynx instances.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_memory_agent.cc`

###### Parameters

| Name        | Type      | Required | Description                                                                                                                                                                                                                                    |
| ----------- | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `timeoutMs` | `integer` | No       | Non-negative integer timeout in milliseconds. Omit the field or pass 0 to let the platform bridge choose its default wait policy. Android and Darwin currently use 2000 ms when the bridge receives 0. Constraints: minimum 0, maximum 300000. |

###### Returns

| Name                                         | Type                            | Description                                                                                                                                      |
| -------------------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `collectionStartMs`                          | `integer`                       | Wall-clock collection start time in milliseconds, as reported by the platform memory collector.                                                  |
| `collectionStatus`                           | `string (completed \| timeout)` | Whether all expected instance fetchers completed or the timeout produced a partial result.                                                       |
| `collectionDurationMs`                       | `integer`                       | Elapsed collection time in milliseconds.                                                                                                         |
| `collectionTimeoutMs`                        | `integer`                       | Timeout in milliseconds used by the platform collector for this request.                                                                         |
| `expectedInstanceCount`                      | `integer`                       | Number of live instance fetchers captured when the request starts.                                                                               |
| `completedInstanceCount`                     | `integer`                       | Number of completed instance results included in this response.                                                                                  |
| `totalBytes`                                 | `integer`                       | Global Lynx-attributed bytes. The total includes element, view, main-thread runtime, and background-thread runtime bytes, and excludes appBytes. |
| `appBytes`                                   | `integer`                       | Current app memory footprint in bytes when the platform reports it.                                                                              |
| `ratioToApp`                                 | `number`                        | totalBytes divided by appBytes. The value is 0 when appBytes is unavailable.                                                                     |
| `elementBytes`                               | `integer`                       | Aggregated element memory in bytes across completed instance results.                                                                            |
| `elementNodeCount`                           | `integer`                       | Aggregated element node count across completed instance results.                                                                                 |
| `viewBytes`                                  | `integer`                       | Aggregated UI view memory in bytes across completed instance results.                                                                            |
| `mainThreadRuntimeBytes`                     | `integer`                       | Aggregated main-thread runtime heap bytes across completed instance results.                                                                     |
| `backgroundThreadRuntimeBytes`               | `integer`                       | Aggregated background-thread runtime heap bytes. Shared background runtime groups are counted once in the global total.                          |
| `instances`                                  | `array`                         | Completed instance memory usage results, sorted by totalBytes descending by the platform result object.                                          |
| `instances[].instanceId`                     | `integer`                       | LynxShell instance id. A value of -1 means the instance was not fully attached.                                                                  |
| `instances[].pageId`                         | `string`                        | Temporary page identity for the instance memory sample. Empty when unavailable.                                                                  |
| `instances[].url`                            | `string`                        | Current template URL captured when the instance fetcher completes. Empty when unavailable.                                                       |
| `instances[].totalBytes`                     | `integer`                       | Instance-attributed total bytes, including element, view, main runtime, and background runtime bytes.                                            |
| `instances[].elementBytes`                   | `integer`                       | Element tree memory in bytes reported for the instance.                                                                                          |
| `instances[].elementNodeCount`               | `integer`                       | Element node count for the instance.                                                                                                             |
| `instances[].viewBytes`                      | `integer`                       | UI view memory in bytes reported for the instance.                                                                                               |
| `instances[].viewDetail`                     | `object`                        | Per-view-category memory detail. Object keys are view categories or tags.                                                                        |
| `instances[].viewDetail.<key>.category`      | `string`                        | View memory category name.                                                                                                                       |
| `instances[].viewDetail.<key>.sizeBytes`     | `integer`                       | Memory size in bytes for the view category.                                                                                                      |
| `instances[].viewDetail.<key>.instanceCount` | `integer`                       | Number of view instances in this category.                                                                                                       |
| `instances[].viewDetail.<key>.detail`        | `object`                        | Category-specific string map reported by the platform memory record.                                                                             |
| `instances[].mainThreadRuntimeBytes`         | `integer`                       | Main-thread runtime heap snapshot bytes for the instance.                                                                                        |
| `instances[].backgroundThreadRuntimeBytes`   | `integer`                       | Background-thread runtime heap snapshot bytes for the instance.                                                                                  |
| `instances[].btsRuntimeGroupId`              | `string`                        | Background runtime group id used by the global result to deduplicate shared background runtime memory. Empty when unavailable.                   |

###### Notes

- Send this method to the global DevTool handler with session ID -1.
- The mediator validates params.timeoutMs before dispatch. Non-object params, non-integer timeoutMs, negative timeoutMs, and timeoutMs values greater than 300000 return CDP errors.
- The platform bridge returns only the result object as JSON. The mediator parses that object and wraps it in the CDP response envelope with the original request id.
- Runtimes without a platform memory bridge return a CDP error instead of a partial memory result.
- This method differs from Runtime.getHeapUsage, which reports JavaScript heap usage for one target runtime.

###### Examples

**Use the platform default timeout**

Request:

```json
{
  "id": 1,
  "method": "Memory.getAllMemoryUsage"
}
```

**Use an explicit timeout**

Request:

```json
{
  "id": 2,
  "method": "Memory.getAllMemoryUsage",
  "params": {
    "timeoutMs": 50000
  }
}
```

### `Memory.startTracing`

Starts platform memory tracing for Lynx memory diagnostics.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_memory_agent.cc`

###### Parameters

No parameters.

###### Returns

| Name     | Type     | Description              |
| -------- | -------- | ------------------------ |
| `result` | `object` | Empty object on success. |

###### Notes

- Use the global DevTool handler with session ID -1 when controlling app-wide memory tracing.
- Dispatches through LynxGlobalDevToolMediator to GlobalDevToolPlatformFacade.StartMemoryTracing.
- Android and Darwin register the DevTool memory controller as a platform memory reporter.
- The generic embedder implementation is a no-op until the embedder supplies a memory bridge.

###### Examples

**Start memory tracing**

Request:

```json
{
  "id": 1,
  "method": "Memory.startTracing"
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

### `Memory.stopTracing`

Stops platform memory tracing for Lynx memory diagnostics.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_memory_agent.cc`

###### Parameters

No parameters.

###### Returns

| Name     | Type     | Description              |
| -------- | -------- | ------------------------ |
| `result` | `object` | Empty object on success. |

###### Notes

- Use the global DevTool handler with session ID -1 when controlling app-wide memory tracing.
- Dispatches through LynxGlobalDevToolMediator to GlobalDevToolPlatformFacade.StopMemoryTracing.
- Android and Darwin unregister the DevTool memory controller from platform memory reporting.
- The generic embedder implementation is a no-op until the embedder supplies a memory bridge.

###### Examples

**Stop memory tracing**

Request:

```json
{
  "id": 1,
  "method": "Memory.stopTracing"
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

