window.AddEventListener("message", ...) in extension content script causes big memory leak

Fixed Issue #13301944

Details

Author
Dominik H.
Created
Aug 17, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
40.15063
Reports
Reported by 3 people

Sign in to watch or report this issue.

Steps to reproduce

When a web page sends (a huge amount of) data with window.postMessage, all memory used by the data object is leaked, when a browser extension content script has an event listener (window.addEventListener("message", ...)) installed.

The problem is simply and clearly reproducible doing the following (see attachment):

  • Host "postmessageleak.html"
  • Install and activate unpacked Edge Extension "MemoryLeakExtension"
  • Navigate to hosted "postmessageleak.html"
  • Optionally open F12
  • Hit “Start Leak Test”
    This will continuously post messages via "window.postMessage" with a string with about 1.7 M characters each.
    Observing the "MicrosoftEdgeCP.exe" processes in task manager shows that memory usage rapidly increases.
  • Hit “Stop Leak Test”
    This stops firing the messages. The memory is not freed and the process consumes about the double amount of totally sent BLOB strings (probably 16 bit characters).
    The total amount of posted data is logged into console.
    When not stopping the leak test, the page runs out of memory and Edge prompts to recover the page (when the process consumes about 4 GB).

When running the memory leak test with disabled extension (or uncommenting adding the event listener in the extension), no memory is leaked, although the web site has also an event listener installed (Memory usage changes between 50 MB and 300 MB on my machine but does not explode).

My test machine is a 64-bit Windows 10 Enterprise, Version 1703, Build 15063.540 with 6 GB RAM.
Edge version: 40.15063.0.0, EdgeHtml version: 15.15063.
“Allow unrestricted memory consumption” is disabled in Edge.

Google Chrome does not leak memory when doing exactly the same.

Regards,
Dominik

Attachments

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Steven K.”

    Changed Assigned To to “Akshay P.”

    Changed Assigned To from “Akshay P.” to “Arif S.”

    Changed Status to “In progress”

  • Hi Dominik,

    I was able to repro this issue on 15063.540.  I also tested on a development build that is a little older than the current public insider fast release of 16273 and the issue was not repro in that build.

    I will close this ticket as "fixed".

    Appreciate this submission and you taking the time to create and run these test cases,

    The MS Edge Team

  • Microsoft Edge Team

    Changed Status from “In progress” to “Fixed”

  • Thank you for looking at this.

    I can confirm that the bug is fixed in Windows 10 Enterprise Insider Preview (Version 1703 OS Build 16251.1000, Edge 41.16251.1000.0 / 16.16251).

    I have found another browser extension memory issue when doing native messaging:

    https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13575575/

    Regards,
    Dominik

  • Thank you for the follow-up.  I will check out your new find. :)

  • Hello,

    the link on this web page to my new memory leak issue seems to be broken.
    It says “Sorry, we couldn’t find that page.”
    Searching for the issue with it’s title "Port.postMessage (Native messaging) causes big memory leak", and clicking on it (first search result) leads to the same problem.
    Other issues in the search result work.

    Regards,
    Dominik

You need to sign in to your Microsoft account to add a comment.

Sign in