Skip to content

Commit

Permalink
Trigger GC when crossing warning threshold on iOS
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273830
rdar://127677553

Reviewed by Geoffrey Garen.

On iOS where we have fairly strict memory limits, sometimes the mutator can get far ahead of the
GC. We might wait until a PROC_LIMIT_CRITICAL event fires before a full GC occurs, at which point
the process is already eligible to be killed by the OS.

To try and reduce the number of foreground OOMs, let's also trigger a full GC if it hasn't occurred
recently when a PROC_LIMIT_WARNING event fires (which is 80% of the critical threshold).

* Source/WebCore/page/MemoryRelease.cpp:
(WebCore::releaseMemory):

Canonical link: https://commits.webkit.org/278567@main
  • Loading branch information
bnham committed May 9, 2024
1 parent 21ed0e0 commit ae91c42
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/WebCore/page/MemoryRelease.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ void releaseMemory(Critical critical, Synchronous synchronous, MaintainBackForwa
{
TraceScope scope(MemoryPressureHandlerStart, MemoryPressureHandlerEnd, static_cast<uint64_t>(critical), static_cast<uint64_t>(synchronous));

#if PLATFORM(IOS_FAMILY)
if (critical == Critical::No)
GCController::singleton().garbageCollectNowIfNotDoneRecently();
#endif

if (critical == Critical::Yes) {
// Return unused pages back to the OS now as this will likely give us a little memory to work with.
WTF::releaseFastMallocFreeMemory();
Expand Down

0 comments on commit ae91c42

Please sign in to comment.