WebKit2.MemoryPressureSettings

Fields

None

Methods

class

new ()

copy ()

free ()

get_conservative_threshold ()

get_kill_threshold ()

get_memory_limit ()

get_poll_interval ()

get_strict_threshold ()

set_conservative_threshold (value)

set_kill_threshold (value)

set_memory_limit (memory_limit)

set_poll_interval (value)

set_strict_threshold (value)

Details

class WebKit2.MemoryPressureSettings

A boxed type representing the settings for the memory pressure handler

WebKit2.MemoryPressureSettings is a boxed type that can be used to provide some custom settings to control how the memory pressure situations are handled by the different processes.

The memory pressure system implemented inside the different process will try to keep the memory usage under the defined memory limit. In order to do that, it will check the used memory with a user defined frequency and decide whether it should try to release memory. The thresholds passed will define how urgent is to release that memory.

Take into account that badly defined parameters can greatly reduce the performance of the engine. For example, setting memory limit too low with a fast poll interval can cause the process to constantly be trying to release memory.

A WebKit2.MemoryPressureSettings can be passed to a WebKit2.WebContext constructor, and the settings will be applied to all the web processes created by that context.

A WebKit2.MemoryPressureSettings can be passed to WebKit2.WebsiteDataManager.set_memory_pressure_settings(), and the settings will be applied to all the network processes created after that call by any instance of WebKit2.WebsiteDataManager.

New in version 2.34.

classmethod new()
Returns:

A new WebKit2.MemoryPressureSettings instance filled with the default values.

Return type:

WebKit2.MemoryPressureSettings

Create a new WebKit2.MemoryPressureSettings with the default values.

New in version 2.34.

copy()
Returns:

A copy of of the passed WebKit2.MemoryPressureSettings.

Return type:

WebKit2.MemoryPressureSettings

Make a copy of self.

New in version 2.34.

free()

Free the WebKit2.MemoryPressureSettings.

New in version 2.34.

get_conservative_threshold()
Returns:

value in the (0, 1) range.

Return type:

float

Gets the conservative memory usage threshold.

New in version 2.34.

get_kill_threshold()
Returns:

positive value, can be zero.

Return type:

float

Gets the kill memory usage threshold.

New in version 2.34.

get_memory_limit()
Returns:

current value, in megabytes.

Return type:

int

Gets the memory usage limit.

New in version 2.34.

get_poll_interval()
Returns:

current interval value, in seconds.

Return type:

float

Gets the interval at which memory usage is checked.

New in version 2.34.

get_strict_threshold()
Returns:

value in the (0, 1) range.

Return type:

float

Gets the strict memory usage threshold.

New in version 2.34.

set_conservative_threshold(value)
Parameters:

value (float) – fraction of the memory limit where the conservative policy starts working.

Sets the memory limit for the conservative policy to start working.

Sets value as the fraction of the defined memory limit where the conservative policy starts working. This policy will try to reduce the memory footprint by releasing non critical memory.

The threshold must be bigger than 0 and smaller than 1, and it must be smaller than the strict threshold defined in self. The default value is 0.33.

New in version 2.34.

set_kill_threshold(value)
Parameters:

value (float) – fraction of the memory limit where the process will be killed because of excessive memory usage.

Sets value as the fraction of the defined memory limit where the process will be killed.

The threshold must be a value bigger or equal to 0. A value of 0 means that the process is never killed. If the threshold is not 0, then it must be bigger than the strict threshold defined in self. The threshold can also have values bigger than 1. The default value is 0.

New in version 2.34.

set_memory_limit(memory_limit)
Parameters:

memory_limit (int) – amount of memory (in MB) that the process is allowed to use.

Sets memory_limit the memory limit value to self.

The default value is the system’s RAM size with a maximum of 3GB.

New in version 2.34.

set_poll_interval(value)
Parameters:

value (float) – period (in seconds) between memory usage measurements.

Sets value as the poll interval used by self.

The poll interval value must be bigger than 0. The default value is 30 seconds.

New in version 2.34.

set_strict_threshold(value)
Parameters:

value (float) – fraction of the memory limit where the strict policy starts working.

Sets the memory limit for the strict policy to start working.

Sets value as the fraction of the defined memory limit where the strict policy starts working. This policy will try to reduce the memory footprint by releasing critical memory.

The threshold must be bigger than 0 and smaller than 1. Also, it must be bigger than the conservative threshold defined in self, and smaller than the kill threshold if the latter is not 0. The default value is 0.5.

New in version 2.34.