-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nwjs seems to leak memory via tray menu items #6583
Comments
Try the sample on Linux/Windows/Mac with nwjs-sdk-v0.30.1, the issue is reproduced. |
This is fixed in git and will be available in the next nightly build. |
Thank you! Will this be in a release soon? |
Yes. Probably in a week.
…On Wed, May 2, 2018 at 10:11 PM Jake Douglas ***@***.***> wrote:
Thank you! Will this be in a release soon?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#6583 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAKGGU2u1-gng75WvSNVIRYKKWcxWrgKks5tub5-gaJpZM4TkTTw>
.
|
btw, the build is here and it's in release quality: |
Thanks! |
Is the nightly build working for you? |
Sorry, I should have checked earlier. It's still leaking. Collections seem to be happening resulting in temporary drops, but the baseline continues to increase. Note that the example seems to produce the leak more quickly when the nwjs window is focused. Test case after ~1 minute: Test case after ~10 minutes: |
Thanks. What about Windows and Linux there? |
It seems to still be leaking on Windows and Linux as well. |
It works for me. Here is the screenshot after running for 10mins, with the nightly build posted above and your example. @Christywl could you please verify as well? |
@Christywl thanks. Does it keeps growing? The specific number doesn't matter because it's decided by GC strategy of v8, which in turn depends on system configuration... |
yes, it keeps growing, but is slower than 0.30.1. |
Does it have upper limit? or it just fills up system memory? And what about the release version on this. |
Do you mean that v8 might decide to continue using more memory until it's close to running out, and only GC then? The example has gone over 300mb on my system now after an hour or two. When should it stop growing in relation to available memory? If this is normal GC behavior and not a leak, is there a way for us to specify the v8 GC settings to collect earlier? The current behavior is likely to give users the impression that our application is a memory hog. |
The GC strategy is a complex topic. It's hard to predict when GC will happen. If you'd like to control it, pass There are various v8 flags to tune GC, see https://github.com/nwjs/v8/blob/nw30/src/flag-definitions.h#L625 0.30.3 will be released today with the fix for Menu and MenuItem leak. We'll continue to find if there are any other leaks with your sample. You can use the heap profiling tool in devtools to see which JS objects are live in the heap after running it for several minutes. Please share your result here. |
btw, you might want to try this for testing purpose: |
By the end of yesterday the example had grown to over 1GB. Today, on the same system, I can no longer reproduce that growth and my results are more like yours. I'm thoroughly confused as to what could have changed. I can still reproduce the growth on another system (Windows). I am adding Nothing obvious is standing out to me since the bulk of the leaked memory seems to be outside of the JS object system and I don't have any sense of what should or shouldn't be present. I've attached both heap snapshots so you can examine them. They're Let me know what else I can provide. |
By "indefinitely" what's the maximum number seen there? And does it lead to out of memory crash? Is there any difference if the arguments are given as in #6583 (comment) ? |
btw, the heap snapshot shows only the live objects in JS heap. It doesn't include the objects that are dead and to be garbage collected. So a normal heap snapshot under increasing memory doesn't imply leak outside of the JS object system. It could be that GC just marked some objects but hasn't decided to return their memory to the system. |
Makes sense. The process calling |
To understand this, see 'mark-sweep' in http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection And calling |
Using We're going to move forward with v0.30.3, hoping that the problem we initially experienced will be improved or fixed in practice. It does seem problematic to me though that memory usage is so difficult to reason about, and that default settings can result in occupying 1GB or more in an example application that does not intentionally hold any significant amount of data in memory. Our nwjs application is run by end users who notice things like ostensibly high memory usage, and it can give them a poor impression. Even if we get an opportunity to explain that the memory might be reclaimed if something else on their system needed it, it's not an easy conversation to have. Thanks for your help! |
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 |
NWJS 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:
tray.menu
a new Menu object that contains new MenuItem objectsmenu.removeAt()
to remove all menu items before adding new onestray.remove()
, creating a new Tray object, then assigning a new Menu objectExpected 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
The text was updated successfully, but these errors were encountered: