Class MemoryPressureSettings
- All Implemented Interfaces:
Proxy
WebKitMemoryPressureSettings
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 WebKitMemoryPressureSettings
can be passed to a WebKitWebContext
constructor, and the settings will
be applied to all the web processes created by that context.
A WebKitMemoryPressureSettings
can be passed to webkit_website_data_manager_set_memory_pressure_settings(),
and the settings will be applied to all the network processes created after that call by any instance of
WebKitWebsiteDataManager
.
-
Constructor Summary
ConstructorDescriptionCreate a newWebKitMemoryPressureSettings
with the default values.MemoryPressureSettings
(MemorySegment address) Create a MemoryPressureSettings proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Make a copy of this MemoryPressureSettings.void
free()
Free theWebKitMemoryPressureSettings
.double
Gets the conservative memory usage threshold.double
Gets the kill memory usage threshold.int
Gets the memory usage limit.double
Gets the interval at which memory usage is checked.double
Gets the strict memory usage threshold.static Type
getType()
Get the GType of the MemoryPressureSettings classvoid
setConservativeThreshold
(double value) Sets the memory limit for the conservative policy to start working.void
setKillThreshold
(double value) Setsvalue
as the fraction of the defined memory limit where the process will be killed.void
setMemoryLimit
(int memoryLimit) SetsmemoryLimit
the memory limit value to this MemoryPressureSettings.void
setPollInterval
(double value) Setsvalue
as the poll interval used by this MemoryPressureSettings.void
setStrictThreshold
(double value) Sets the memory limit for the strict policy to start working.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
MemoryPressureSettings
Create a MemoryPressureSettings proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
MemoryPressureSettings
Create a newWebKitMemoryPressureSettings
with the default values.- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
Method Details
-
getType
-
copy
Make a copy of this MemoryPressureSettings.- Returns:
- A copy of of the passed
WebKitMemoryPressureSettings
.
-
free
public void free()Free theWebKitMemoryPressureSettings
. -
getConservativeThreshold
public double getConservativeThreshold()Gets the conservative memory usage threshold.- Returns:
- value in the
(0, 1)
range.
-
getKillThreshold
public double getKillThreshold()Gets the kill memory usage threshold.- Returns:
- positive value, can be zero.
-
getMemoryLimit
public int getMemoryLimit()Gets the memory usage limit.- Returns:
- current value, in megabytes.
-
getPollInterval
public double getPollInterval()Gets the interval at which memory usage is checked.- Returns:
- current interval value, in seconds.
-
getStrictThreshold
public double getStrictThreshold()Gets the strict memory usage threshold.- Returns:
- value in the
(0, 1)
range.
-
setConservativeThreshold
public void setConservativeThreshold(double value) 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 this MemoryPressureSettings. The default value is 0.33.
- Parameters:
value
- fraction of the memory limit where the conservative policy starts working.
-
setKillThreshold
public void setKillThreshold(double value) Setsvalue
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 this MemoryPressureSettings. The threshold can also have values bigger than 1. The default value is 0.
- Parameters:
value
- fraction of the memory limit where the process will be killed because of excessive memory usage.
-
setMemoryLimit
public void setMemoryLimit(int memoryLimit) SetsmemoryLimit
the memory limit value to this MemoryPressureSettings.The default value is the system's RAM size with a maximum of 3GB.
- Parameters:
memoryLimit
- amount of memory (in MB) that the process is allowed to use.
-
setPollInterval
public void setPollInterval(double value) Setsvalue
as the poll interval used by this MemoryPressureSettings.The poll interval value must be bigger than 0. The default value is 30 seconds.
- Parameters:
value
- period (in seconds) between memory usage measurements.
-
setStrictThreshold
public void setStrictThreshold(double value) 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 this MemoryPressureSettings, and smaller than the kill threshold if the latter is not 0. The default value is 0.5.
- Parameters:
value
- fraction of the memory limit where the strict policy starts working.
-