[webkit-changes] [WebKit/WebKit] 0668d8: Ask system malloc to free up memory in non-visible...

Cameron McCormack noreply at github.com
Thu Mar 2 11:35:58 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0668d887feed861cb082fe8cea267f1055c5bb49
      https://github.com/WebKit/WebKit/commit/0668d887feed861cb082fe8cea267f1055c5bb49
  Author: Cameron McCormack <heycam at apple.com>
  Date:   2023-03-02 (Thu, 02 Mar 2023)

  Changed paths:
    M Source/WebKit/WebProcess/WebProcess.cpp
    M Source/WebKit/WebProcess/WebProcess.h
    M Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

  Log Message:
  -----------
  Ask system malloc to free up memory in non-visible Web processes
https://bugs.webkit.org/show_bug.cgi?id=253173
rdar://106009868

Reviewed by Geoffrey Garen.

We currently do some memory reduction work in non-visible Web processes (those
that only have background tabs) off a timer. We can ask the system malloc to
free up memory off one of these timers too.

malloc_zone_pressure_relief will block the thread it's called on, so we
call it on a background thread, which is allowed. Local testing shows it
can run for several ms, but it will only cause regular malloc
contention, not block other threads entirely.

This patch repurposes the "graphics cleanup timer" to be an "early
memory cleanup timer", and we perform the system malloc cleanup off it.
The more aggressive cleanup tasks that can clear caches etc. remain off
the other memory cleanup timer, which runs later.

* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::pageDidEnterWindow):
(WebKit::WebProcess::pageWillLeaveWindow):
(WebKit::WebProcess::nonVisibleProcessEarlyMemoryCleanupTimerFired):
(WebKit::WebProcess::nonVisibleProcessGraphicsCleanupTimerFired): Deleted.
* Source/WebKit/WebProcess/WebProcess.h:
* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::releaseSystemMallocMemory):

Canonical link: https://commits.webkit.org/261087@main




More information about the webkit-changes mailing list