[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?

[cid:c5e7870a-3549-4b2b-83cd-2ce8bed42602]


  *   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?

Thanks!
Joe


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:

https://webkit.org/blog/6425/memory-debugging-with-web-inspector/<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwebkit.org%2Fblog%2F6425%2Fmemory-debugging-with-web-inspector%2F&data=04%7C01%7Cjoliccin%40microsoft.com%7Cf7bfe7749af349ebd5e008d8efddc917%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637523083745299393%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=LLDRWu%2BVkBK0gaXXDz2XrNEE8FiXLAdSjpc4juEfRY8%3D&reserved=0>

For code-level memory debugging, these are good starting places:
https://trac.webkit.org/wiki/Memory%20Use<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftrac.webkit.org%2Fwiki%2FMemory%2520Use&data=04%7C01%7Cjoliccin%40microsoft.com%7Cf7bfe7749af349ebd5e008d8efddc917%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637523083745309349%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Xj28GHBQphvRYyrrJAR9E62bM6XLruQm3aRLjudcPXs%3D&reserved=0>
https://trac.webkit.org/wiki/InvestigatingLeaksAndBloat<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftrac.webkit.org%2Fwiki%2FInvestigatingLeaksAndBloat&data=04%7C01%7Cjoliccin%40microsoft.com%7Cf7bfe7749af349ebd5e008d8efddc917%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637523083745309349%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=uh%2BWDwsQa7GFHi8Npraa33H9A5fSyx1CAg3%2FDoIMfvU%3D&reserved=0>

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

Simon

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.

Thanks!
Joe

-------------- 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