Lynx

Memory

本页面介绍 Lynx DevTool 支持的 Memory CDP domain。

实验性参考

此生成的参考文档仍在完善中。

  • CDP events 尚未包含。
  • 部分 Lynx 扩展已列出,但尚未提供详细文档。
  • 方法说明尚未根据实现自动校验,可能不完整或不准确。

在依赖本参考前,请根据实现及所链接的 upstream CDP reference 验证实际行为。

概览

  • 作用域:global-and-instance
  • CDP domain:Memory

Lynx 扩展

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
参数
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.
返回字段
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.
备注
  • 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.
示例

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
参数

无参数。

返回字段
NameTypeDescription
resultobjectEmpty object on success.
备注
  • 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.
示例

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
参数

无参数。

返回字段
NameTypeDescription
resultobjectEmpty object on success.
备注
  • 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.
示例

Stop memory tracing

Request:

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

Response:

{
  "id": 1,
  "result": {}
}
除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。