You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
memory leak with multiple open/close BrowserWindows and using affinity #12027
Leaks memory at the closing of each new same affinity browser window
How to reproduce
Create a BrowserWindow with affinity of 'test'
Have a way of creating and closing a child window with a basic renderer html with affinity of 'test'
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)
Reacted by Daniel Pereira, Shafqat Bhuiyan, cynx and Nicolas Boutet
👋 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.
+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.
+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
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.
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.
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.
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:
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.
Activity
welcome commentedon Feb 23, 2018
👋 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.
KochiyaOcean commentedon Mar 14, 2018
An example can be found in https://github.com/KochiyaOcean/electron-bugs/tree/affinity-memory-leak


Memory usage on startup:
About 30s later:
Hammster commentedon Jun 6, 2018
+1 I also encountered this issue today, this also happens when i reaload via
ctrl+rwith focused devtools. The render process loads just a empty html5 skeleton.localh0rzd commentedon Jun 15, 2018
+1 encountered while using multiple
<webview>sharing one affinity. Creating and later removing the WebView leaks memory.Gvozd commentedon Jul 11, 2018
+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
jaehayoo commentedon Dec 4, 2018
So, Is there any update for this issue?
Garbee commentedon Jan 6, 2019
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.
sofianguy commentedon Aug 9, 2019
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-infolabel 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.
Garbee commentedon Aug 9, 2019
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.
Ter01an commentedon Oct 16, 2019
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
ewok-janitor commentedon Nov 7, 2019
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:
I do not know how to fix the GC root issue.
Jun90925 commentedon Jul 20, 2020
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.
dingchaoyan1983 commentedon Jul 29, 2020
any update for this issue?
Garbee commentedon Jul 31, 2020
10.x is planning to remove affinity. Plan for this functionality to no longer exist shortly unless something changes with the plans.
electron-triage commentedon Mar 8, 2021
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.
knownasilya commentedon Jul 6, 2021
Still an issue, even without affinity (note comment here #12027 (comment))