Skip to content

Commit 96f63c6

Browse files
committed
JSC: make JSC aware of the memory limits set to the MemoryPressureHandler
1 parent 6db4c0c commit 96f63c6

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Source/JavaScriptCore/heap/Heap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
#include <algorithm>
8888
#include <wtf/CryptographicallyRandomNumber.h>
8989
#include <wtf/ListDump.h>
90+
#include <wtf/MemoryPressureHandler.h>
9091
#include <wtf/RAMSize.h>
9192
#include <wtf/Scope.h>
9293
#include <wtf/SimpleStats.h>
@@ -678,6 +679,7 @@ bool Heap::overCriticalMemoryThreshold(MemoryThresholdCallType memoryThresholdCa
678679
#if USE(BMALLOC_MEMORY_FOOTPRINT_API)
679680
if (memoryThresholdCallType == MemoryThresholdCallType::Direct || ++m_percentAvailableMemoryCachedCallCount >= 100) {
680681
m_overCriticalMemoryThreshold = bmalloc::api::percentAvailableMemoryInUse() > Options::criticalGCMemoryThreshold();
682+
m_overCriticalMemoryThreshold |= bmalloc::api::memoryFootprint() > MemoryPressureHandler::singleton().criticalMemoryThreshold();
681683
m_percentAvailableMemoryCachedCallCount = 0;
682684
}
683685

Source/WTF/wtf/MemoryPressureHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class MemoryPressureHandler {
140140

141141
void setMemoryPressureStatus(SystemMemoryPressureStatus);
142142
SystemMemoryPressureStatus memoryPressureStatus() const { return m_memoryPressureStatus; }
143+
double criticalMemoryThreshold() const { return m_configuration.baseThreshold * m_configuration.strictThresholdFraction; }
143144

144145
WTF_EXPORT_PRIVATE MemoryUsagePolicy currentMemoryUsagePolicy();
145146

0 commit comments

Comments
 (0)