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 cdp.memory.PressureLevel

Memory pressure level.

CRITICAL = 'critical'
MODERATE = 'moderate'
class cdp.memory.SamplingProfileNode(size, total, stack)

Heap profile sample.

size = None

Size of the sampled allocation.

stack = None

Execution stack at the point of allocation.

total = None

Total bytes attributed to this sample.

class cdp.memory.SamplingProfile(samples, modules)

Array of heap profile samples.

class cdp.memory.Module(name, uuid, base_address, size)

Executable module information

base_address = None

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

name = None

Name of the module.

size = None

Size of the module in bytes.

uuid = None

UUID of the module.

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.

cdp.memory.forcibly_purge_java_script_memory()

Simulate OomIntervention by purging V8 memory.

Return type:Generator[Dict[str, Any], Dict[str, Any], None]
cdp.memory.get_all_time_sampling_profile()

Retrieve native memory allocations profile collected since renderer process startup.

Return type:Generator[Dict[str, Any], Dict[str, Any], SamplingProfile]
Returns:
cdp.memory.get_browser_sampling_profile()

Retrieve native memory allocations profile collected since browser process startup.

Return type:Generator[Dict[str, Any], Dict[str, Any], SamplingProfile]
Returns:
cdp.memory.get_dom_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 -
cdp.memory.get_sampling_profile()

Retrieve native memory allocations profile collected since last startSampling call.

Return type:Generator[Dict[str, Any], Dict[str, Any], SamplingProfile]
Returns:
cdp.memory.prepare_for_leak_detection()
Return type:Generator[Dict[str, Any], Dict[str, Any], None]
cdp.memory.set_pressure_notifications_suppressed(suppressed)

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]
cdp.memory.simulate_pressure_notification(level)

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]
cdp.memory.start_sampling(sampling_interval=None, suppress_randomness=None)

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]

cdp.memory.stop_sampling()

Stop collecting native memory profile.

Return type:Generator[Dict[str, Any], Dict[str, Any], None]

Events

There are no events in this module.