nwjs seems to leak memory via tray menu items
See original GitHub issueNWJS Version : v0.30.1 Operating System : macOS 10.13.4. Other platforms might be affected as well.
The documentation is not explicit about how a tray/menu should be refreshed/manipulated after creation. However, I have tried the following approaches that all seem to result in increasing memory usage:
- Simply reassigning
tray.menu
a new Menu object that contains new MenuItem objects - Using
menu.removeAt()
to remove all menu items before adding new ones - Using
tray.remove()
, creating a new Tray object, then assigning a new Menu object - Approaches 2 and 3 combined
Expected behavior
Memory usage should not grow indefinitely as the tray menu is refreshed.
Actual behavior
Memory usage continues to grow as the tray menu is refreshed.
How to reproduce
<!DOCTYPE html>
<html>
<head>
<title>Hi</title>
</head>
<body style="width: 100%; height: 100%;">
<script>
const tray = new nw.Tray({ title: 'Tray' });
setInterval(() => {
const menu = new nw.Menu();
menu.append(new nw.MenuItem({ type: 'normal', label: 'A' }));
menu.append(new nw.MenuItem({ type: 'normal', label: 'B' }));
menu.append(new nw.MenuItem({ type: 'normal', label: 'C' }));
tray.menu = menu;
}, 10)
</script>
</body>
</html>
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (18 by maintainers)
Top Results From Across the Web
Developers - nwjs seems to leak memory via tray menu items -
nwjs seems to leak memory via tray menu items. ... The documentation is not explicit about how a tray/menu should be refreshed/manipulated after...
Read more >nwjs/nw.js - Gitter
hi i would like to create a node webkit app that would work both on win32 and win64 it eill check using command...
Read more >Flush all memory on reload in NW.js - Stack Overflow
I made another simple app with only a couple of variables, and the same memory leak appeared when reload. I tried the NW.js...
Read more >Tray - NW.js Documentation
The reason is that the tray and even the web page will be garbage collected by JS engine after navigation to prevent memory...
Read more >RMMV tips: Upgrade NWJS and Chromium 67,68 64bits
We go here to see for the beginner how to update nwjs ... the 64bits version will unlock you very higth performance memory...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes. Probably in a week.
On Wed, May 2, 2018 at 10:11 PM Jake Douglas notifications@github.com wrote:
I agree with you that 1GB memory consumption is big but this is from an extreme benchmark that allocating objects every 10ms. The real world application may or may not behave like this. Note that the default v8 behavior on this is tuned for trade-off between garbage collection throughput, latency, and memory consumption. See more information here: https://v8project.blogspot.com/2016/10/fall-cleaning-optimizing-v8-memory.html
And it can always be tuned for your use case with appropriate
js-flags
for smaller memory footprint.