[webkit-help] [EXTERNAL] Re: Debugging Memory Leaks in WebKit

Joe Liccini joliccin at microsoft.com
Thu Apr 1 16:41:46 PDT 2021

Thanks for the tips, Simon.

I haven't forgotten about the trace collection; I plan on getting to it soon. I have been continuing to read through source code and had some additional questions.

I am reading up on WebKit architecture <https://github.com/WebKit/WebKit/blob/main/Introduction.md> and found this note:

WebContent process - This process loads & runs code loaded from websites. Each tab in Safari typically has its own WebContent process. This is important to keep each tab responsive and protect websites from one another.

>From my testing and personal debugging, I am observing this behavior:

  1.  User initiates a new tab (i.e., user clicks on + New Tab button in Safari), it gets a new WebKitWebProcess
  2.  User clicks a button that runs window.open('https://www.microsoft.com', '_blank'), the new page is added to the same WebKitWebProcess, yet different tab. (i.e., they share the same process and therefore process memory).

  *   Is this behavior accurate and representative or am I missing something?

In addition, I found some memory pressure handling code here: https://github.com/WebKit/WebKit/blob/dbed638e9975b00d206546a3f0294db75ff0f0c0/Source/WTF/wtf/MemoryPressureHandler.cpp#L129-L152

  *   Is this the code that triggers this banner in Safari?


  *   If so, how does the grouping of tabs / webpages in a single WebKitWebProcess affect this banner?
  *   Is WebKit able to determine which of the webpages within the process is causing memory pressure?
  *   Is the presence of this banner a clear giveaway that the leak is indeed from the WebContents and not within the WebKit engine itself?


Sent from Outlook<http://aka.ms/weboutlook>

From: Simon Fraser <simon.fraser at apple.com>
Sent: Thursday, March 25, 2021 3:31 PM
To: Joe Liccini <joliccin at microsoft.com>
Cc: webkit-help at lists.webkit.org <webkit-help at lists.webkit.org>
Subject: [EXTERNAL] Re: [webkit-help] Debugging Memory Leaks in WebKit

The first step should be to figure out whether the memory is being triggered by page content; you can do that by inspecting the JS Heap via Web Inspector:


For code-level memory debugging, these are good starting places:

Once you know a bit more about the memory growth, report back and we can direct you.


On Mar 25, 2021, at 3:03 PM, Joe Liccini <joliccin at microsoft.com<mailto:joliccin at microsoft.com>> wrote:

Hi WebKit Help,

I am investigating what I believe is a memory leak in WebKit that is manifesting as high memory usage for Office 365 online apps (Word, Excel, PowerPoint, etc.) for Safari users.

I have downloaded and built the source of WebKit, and by opening and closing a document or two, can very quickly get the memory utilization of WebKitWebProcess beyond 1 GB.

I was wondering if anyone here has experience investigating memory leaks on WebKit? I can attach via the debugger but I'm not familiar enough with the code or tools to best identify common sources of memory leaks.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20210401/fe7e08d5/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 117738 bytes
Desc: image.png
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20210401/fe7e08d5/attachment-0001.png>

More information about the webkit-help mailing list