Skip to content

Commit c888663

Browse files
committed
[MemoryPressure] Fix video memory limit set through env var not overwriting API value
1 parent e7dd204 commit c888663

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

Source/WTF/wtf/MemoryPressureHandler.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static const Seconds s_pollInterval = 30_s;
5353
// This file contains the amount of video memory used, and will be filled by some other
5454
// platform component. It's a text file containing an unsigned integer value.
5555
static String s_GPUMemoryFile;
56+
static ssize_t s_envBaseThresholdVideo = 0;
5657

5758
static bool isWebProcess()
5859
{
@@ -135,7 +136,9 @@ MemoryPressureHandler::MemoryPressureHandler()
135136
units = MB;
136137
if (units != 1)
137138
value = value.substring(0, value.length() - 1);
138-
m_configuration.baseThresholdVideo = parseInteger<size_t>(value).value_or(0) * units;
139+
s_envBaseThresholdVideo = parseInteger<size_t>(value).value_or(0) * units;
140+
if (s_envBaseThresholdVideo)
141+
m_configuration.baseThresholdVideo = s_envBaseThresholdVideo;
139142
}
140143
}
141144
}
@@ -348,6 +351,20 @@ void MemoryPressureHandler::endSimulatedMemoryPressure()
348351
memoryPressureStatusChanged();
349352
}
350353

354+
void MemoryPressureHandler::setConfiguration(Configuration&& configuration)
355+
{
356+
m_configuration = WTFMove(configuration);
357+
if (s_envBaseThresholdVideo)
358+
m_configuration.baseThresholdVideo = s_envBaseThresholdVideo;
359+
}
360+
361+
void MemoryPressureHandler::setConfiguration(const Configuration& configuration)
362+
{
363+
m_configuration = configuration;
364+
if (s_envBaseThresholdVideo)
365+
m_configuration.baseThresholdVideo = s_envBaseThresholdVideo;
366+
}
367+
351368
void MemoryPressureHandler::releaseMemory(Critical critical, Synchronous synchronous)
352369
{
353370
if (!m_lowMemoryHandler)

Source/WTF/wtf/MemoryPressureHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ class MemoryPressureHandler {
224224
std::optional<double> killThresholdFraction;
225225
Seconds pollInterval;
226226
};
227-
void setConfiguration(Configuration&& configuration) { m_configuration = WTFMove(configuration); }
228-
void setConfiguration(const Configuration& configuration) { m_configuration = configuration; }
227+
void setConfiguration(Configuration&& configuration);
228+
void setConfiguration(const Configuration& configuration);
229229

230230
WTF_EXPORT_PRIVATE void releaseMemory(Critical, Synchronous = Synchronous::No);
231231

0 commit comments

Comments
 (0)