Lynx

Memory

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

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

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
NameTypeRequiredDescription
timeoutMsintegerNoNon-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
NameTypeDescription
collectionStartMsintegerWall-clock collection start time in milliseconds, as reported by the platform memory collector.
collectionStatusstring (completed | timeout)Whether all expected instance fetchers completed or the timeout produced a partial result.
collectionDurationMsintegerElapsed collection time in milliseconds.
collectionTimeoutMsintegerTimeout in milliseconds used by the platform collector for this request.
expectedInstanceCountintegerNumber of live instance fetchers captured when the request starts.
completedInstanceCountintegerNumber of completed instance results included in this response.
totalBytesintegerGlobal Lynx-attributed bytes. The total includes element, view, main-thread runtime, and background-thread runtime bytes, and excludes appBytes.
appBytesintegerCurrent app memory footprint in bytes when the platform reports it.
ratioToAppnumbertotalBytes divided by appBytes. The value is 0 when appBytes is unavailable.
elementBytesintegerAggregated element memory in bytes across completed instance results.
elementNodeCountintegerAggregated element node count across completed instance results.
viewBytesintegerAggregated UI view memory in bytes across completed instance results.
mainThreadRuntimeBytesintegerAggregated main-thread runtime heap bytes across completed instance results.
backgroundThreadRuntimeBytesintegerAggregated background-thread runtime heap bytes. Shared background runtime groups are counted once in the global total.
instancesarrayCompleted instance memory usage results, sorted by totalBytes descending by the platform result object.
instances[].instanceIdintegerLynxShell instance id. A value of -1 means the instance was not fully attached.
instances[].pageIdstringTemporary page identity for the instance memory sample. Empty when unavailable.
instances[].urlstringCurrent template URL captured when the instance fetcher completes. Empty when unavailable.
instances[].totalBytesintegerInstance-attributed total bytes, including element, view, main runtime, and background runtime bytes.
instances[].elementBytesintegerElement tree memory in bytes reported for the instance.
instances[].elementNodeCountintegerElement node count for the instance.
instances[].viewBytesintegerUI view memory in bytes reported for the instance.
instances[].viewDetailobjectPer-view-category memory detail. Object keys are view categories or tags.
instances[].viewDetail.<key>.categorystringView memory category name.
instances[].viewDetail.<key>.sizeBytesintegerMemory size in bytes for the view category.
instances[].viewDetail.<key>.instanceCountintegerNumber of view instances in this category.
instances[].viewDetail.<key>.detailobjectCategory-specific string map reported by the platform memory record.
instances[].mainThreadRuntimeBytesintegerMain-thread runtime heap snapshot bytes for the instance.
instances[].backgroundThreadRuntimeBytesintegerBackground-thread runtime heap snapshot bytes for the instance.
instances[].btsRuntimeGroupIdstringBackground 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:

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

Use an explicit timeout

Request:

{
  "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
NameTypeDescription
resultobjectEmpty 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:

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

Response:

{
  "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
NameTypeDescription
resultobjectEmpty 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:

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

Response:

{
  "id": 1,
  "result": {}
}
Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.