Memory#

This CDP domain is experimental.

Types#

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

class PressureLevel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Memory pressure level.

MODERATE = 'moderate'#
CRITICAL = 'critical'#
class SamplingProfileNode(size, total, stack)[source]#

Heap profile sample.

size: float#

Size of the sampled allocation.

total: float#

Total bytes attributed to this sample.

stack: List[str]#

Execution stack at the point of allocation.

class SamplingProfile(samples, modules)[source]#

Array of heap profile samples.

samples: List[SamplingProfileNode]#
modules: List[Module]#
class Module(name, uuid, base_address, size)[source]#

Executable module information

name: str#

Name of the module.

uuid: str#

UUID of the module.

base_address: str#

Base address where the module is loaded into memory. Encoded as a decimal or hexadecimal (0x prefixed) string.

size: float#

Size of the module in bytes.

class DOMCounter(name, count)[source]#

DOM object counter data.

name: str#

object names should be presumed volatile and clients should not expect the returned names to be consistent across runs.

Type:

Object name. Note

count: int#

Object count.

Commands#

Each command is a generator function. The return type Generator[x, y, z] indicates that the generator yields arguments of type x, it must be resumed with an argument of type y, and it returns type z. In this library, types x and y are the same for all commands, and z is the return type you should pay attention to. For more information, see Getting Started: Commands.

forcibly_purge_java_script_memory()[source]#

Simulate OomIntervention by purging V8 memory.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

get_all_time_sampling_profile()[source]#

Retrieve native memory allocations profile collected since renderer process startup.

Return type:

Generator[Dict[str, Any], Dict[str, Any], SamplingProfile]

Returns:

get_browser_sampling_profile()[source]#

Retrieve native memory allocations profile collected since browser process startup.

Return type:

Generator[Dict[str, Any], Dict[str, Any], SamplingProfile]

Returns:

get_dom_counters()[source]#

Retruns current DOM object counters.

Return type:

Generator[Dict[str, Any], Dict[str, Any], Tuple[int, int, int]]

Returns:

A tuple with the following items:

  1. documents -

  2. nodes -

  3. jsEventListeners -

get_dom_counters_for_leak_detection()[source]#

Retruns DOM object counters after preparing renderer for leak detection.

Return type:

Generator[Dict[str, Any], Dict[str, Any], List[DOMCounter]]

Returns:

DOM object counters.

get_sampling_profile()[source]#

Retrieve native memory allocations profile collected since last startSampling call.

Return type:

Generator[Dict[str, Any], Dict[str, Any], SamplingProfile]

Returns:

prepare_for_leak_detection()[source]#

Prepares for leak detection by terminating workers, stopping spellcheckers, dropping non-essential internal caches, running garbage collections, etc.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

set_pressure_notifications_suppressed(suppressed)[source]#

Enable/disable suppressing memory pressure notifications in all processes.

Parameters:

suppressed (bool) – If true, memory pressure notifications will be suppressed.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

simulate_pressure_notification(level)[source]#

Simulate a memory pressure notification in all processes.

Parameters:

level (PressureLevel) – Memory pressure level of the notification.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

start_sampling(sampling_interval=None, suppress_randomness=None)[source]#

Start collecting native memory profile.

Parameters:
  • sampling_interval (Optional[int]) – (Optional) Average number of bytes between samples.

  • suppress_randomness (Optional[bool]) – (Optional) Do not randomize intervals between samples.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

stop_sampling()[source]#

Stop collecting native memory profile.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

Events#

There are no events in this module.