Skip to content

window.open with nativeWindowOpen option causes memory leak #12634

Closed

Description

@KochiyaOcean
  • Electron version: 2.0.0-beta.7
  • Operating system: Windows 10 x64

Expected behavior

When webPreferences.nativeWindowOpen is set to true, BrowserWindows opened by window.open's memory will be released after be closed.

Actual behavior

The memory is not released and caused memory leak

How to reproduce

Activity

  1. KochiyaOcean commented on Apr 17, 2018

    @KochiyaOcean
    Author

    Seems this issue is relative to #12027

  2. MarshallOfSound commented on Apr 26, 2018

    @MarshallOfSound
    Member

    Appears to occur on all known Electron versions with this feature 👍 Approximately 5MB per window

  3. KochiyaOcean commented on May 6, 2018

    @KochiyaOcean
    Author

    Still occurs on 2.0.0 stable

  4. GhostDev26 commented on Sep 17, 2018

    @GhostDev26

    Still occurs on 2.0.9

  5. VishwasShashidhar commented on Sep 26, 2018

    @VishwasShashidhar

    We've observed this on 3.0.0 as well.

  6. assigned and unassigned on Oct 9, 2018
  7. zcbenz commented on Oct 10, 2018

    @zcbenz
    Contributor

    From the profile of heap allocations, it seems that the V8 contexts of the new windows have never been released, resulting in a leak of V8 contexts in the renderer process of the embedder page.

  8. zcbenz commented on Oct 10, 2018

    @zcbenz
    Contributor

    A theory for this leak is: since we don't release Node environment when a page is destroyed (because of crashes), the V8 context of the pages become persistent in memory.

    This is kind of expected behavior since the leak is intended, and it is also part of the reasons why we restart renderer process for every page navigation. The nativeWindowOpen option actually violates the design of Electron's Node integration model.

    The simplest fix should be disabling Node integration for the new windows, but it would be a breaking change.

  9. VishwasShashidhar commented on Oct 12, 2018

    @VishwasShashidhar

    @zcbenz Thanks for the details. Is there a work-around for this at the moment?

    Edit: Never mind, I just saw that a PR was raised to fix this issue for when nodeIntegration is disabled in the child window.

  10. orange4glace commented on Nov 27, 2018

    @orange4glace

    Tested on nightly build version, (4.0.0-nightly.201) it seems it's still happening even nodeIntegration is disabled.

  11. KochiyaOcean commented on Nov 27, 2018

    @KochiyaOcean
    Author

    @orange4glace #15666 seems it will be fixed in 5.0.x release.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions