Skip to content

memory leak with multiple open/close BrowserWindows and using affinity #12027

Closed

Description

@waistcoat1971
  • Electron version: 2.0.0-beta.1
  • Operating system: Windows 7

Expected behavior

Not leak!

Actual behavior

Leaks memory at the closing of each new same affinity browser window

How to reproduce

  1. Create a BrowserWindow with affinity of 'test'
  2. Have a way of creating and closing a child window with a basic renderer html with affinity of 'test'
  3. each cycle leaks a large amount of memory

This occurs no matter what is in the renderer html.
Occurs whether or not you hook any browserwindow events
Doesn't occur if you DON'T call loadUrl. (obviously not much use)

Activity

  1. welcome commented on Feb 23, 2018

    @welcome

    👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

    To help make it easier for us to investigate your issue, please follow the contributing guidelines.

  2. KochiyaOcean commented on Mar 14, 2018

    @KochiyaOcean
  3. Hammster commented on Jun 6, 2018

    @Hammster

    +1 I also encountered this issue today, this also happens when i reaload via ctrl+r with focused devtools. The render process loads just a empty html5 skeleton.

  4. localh0rzd commented on Jun 15, 2018

    @localh0rzd

    +1 encountered while using multiple <webview> sharing one affinity. Creating and later removing the WebView leaks memory.

  5. Gvozd commented on Jul 11, 2018

    @Gvozd

    +1
    Also, after restarting the window, the time of file operations increases
    Before rebooting around 20ms
    After a reboot, it ranges from 500ms to 22 seconds

  6. jaehayoo commented on Dec 4, 2018

    @jaehayoo

    So, Is there any update for this issue?

  7. Garbee commented on Jan 6, 2019

    @Garbee

    This is not just Windows. It also affects MacOS. Since it exists here, I'd suspect it does the same on Linux. Manual testing on Linux hasn't happened yet to confirm.

  8. sofianguy commented on Aug 9, 2019

    @sofianguy
    Contributor

    Thank you for taking the time to report this issue and helping to make Electron better.

    The version of Electron you reported this on has been superseded by newer releases.

    If you're still experiencing this issue in Electron v4.2.x or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

    I'm setting the blocked/need-info label for the above reasons. This issue will be closed 7 days from now if there is no response.

    Thanks in advance! Your help is appreciated.

  9. added
    blocked/need-info ❌
    on Aug 9, 2019
  10. Garbee commented on Aug 9, 2019

    @Garbee

    The problem is still occurring on Electron 6.0.1 using the test provided by @KochiyaOcean. At least on Mac OS, but Windows should still exhibit the same behavior.

  11. added and removed
    blocked/need-info ❌
    on Aug 9, 2019
  12. Ter01an commented on Oct 16, 2019

    @Ter01an

    Is there a way to free memory before the problem is resolved? I call a lot of windows and rest on the fact that the application crashes at some point

  13. ewok-janitor commented on Nov 7, 2019

    @ewok-janitor

    I was getting a memory leak in a similar situation (not using affinity). Opening and closing BrowserWindows leaks "BrowserWindow" objects. They appear to be rooted to a GC handle. I was also getting messages in the console about "too many event listeners".

    I was able to fix the "too many event listeners" by this code:

        this.browserWindow.on('close', (e)=>{
          app.removeAllListeners("browser-window-created")
        });
    

    I do not know how to fix the GC root issue.

  14. Jun90925 commented on Jul 20, 2020

    @Jun90925

    The problem is still occurring on Electron 8.4.0, macos. Close a BrowserWindow does not free the memory of main process.
    The memory of main process will keep rising when open BrowserWindows.

  15. dingchaoyan1983 commented on Jul 29, 2020

    @dingchaoyan1983

    any update for this issue?

  16. Garbee commented on Jul 31, 2020

    @Garbee

    10.x is planning to remove affinity. Plan for this functionality to no longer exist shortly unless something changes with the plans.

  17. electron-triage commented on Mar 8, 2021

    @electron-triage

    The Electron version reported on this issue is no longer supported. See our supported versions documentation.

    If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.

    Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.

  18. knownasilya commented on Jul 6, 2021

    @knownasilya

    Still an issue, even without affinity (note comment here #12027 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions