File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434#include < wtf/MemoryFootprint.h>
3535#include < wtf/NeverDestroyed.h>
3636#include < wtf/RAMSize.h>
37+ #include < wtf/text/StringToIntegerConversion.h>
3738
3839namespace WTF {
3940
@@ -120,9 +121,23 @@ MemoryPressureHandler::MemoryPressureHandler()
120121#endif
121122
122123 // If this is the WebProcess, Check whether the env var WPE_POLL_MAX_MEMORY_GPU_FILE exists, containing the file
123- // that we need to poll to get the video memory used.
124- if (isWebProcess ())
124+ // that we need to poll to get the video memory used, and whether WPE_POLL_MAX_MEMORY_GPU exists, overriding the
125+ // limit for video memory set by the API.
126+ if (isWebProcess ()) {
125127 s_GPUMemoryFile = String::fromLatin1 (getenv (" WPE_POLL_MAX_MEMORY_GPU_FILE" ));
128+ String s = String::fromLatin1 (getenv (" WPE_POLL_MAX_MEMORY_GPU" ));
129+ if (!s.isEmpty ()) {
130+ String value = s.stripWhiteSpace ().convertToLowercaseWithoutLocale ();
131+ size_t units = 1 ;
132+ if (value.endsWith (' k' ))
133+ units = KB;
134+ else if (value.endsWith (' m' ))
135+ units = MB;
136+ if (units != 1 )
137+ value = value.substring (0 , value.length () - 1 );
138+ m_configuration.baseThresholdVideo = parseInteger<size_t >(value).value_or (0 ) * units;
139+ }
140+ }
126141}
127142
128143void MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor (bool use)
You can’t perform that action at this time.
0 commit comments