-
Notifications
You must be signed in to change notification settings - Fork 394
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
memory leaks with monitors #194
Comments
Hi @ashwinr. Even though it's a debugging aid, I'd certainly love to squash any memory leaks caused by the monitor. It's not clear to me from the screenshot, though, what exactly is being leaked, or by whom. Could you please provide more detail on what you think is happening? The monitor will keep some references in a hash until a promise is either fulfilled, rejected, or I'll look into the graph, but if you can also provide more info, that would be very helpful. Thanks! |
sure, the problem is that saving off the promise creation stack retains references to objects along the stack. And this is never cleaned up. My "fix"[https://github.com/ashwinr/when/commit/23fcbeb170492bf496ce65add7bdd4d7a76859dc] was to just remove the creation stack altogether as the failure stack is more useful than the stack at the time of promise creation. |
Hmm, I don't believe this is the case. Saving an exception or stack trace does not pin objects that were allocated on those stack frames into memory. In fact, stack traces are generated lazily in most VMs now (the That said, the change you made also prevents the monitor from stitching together long stack traces. It uses the in-memory promise graph to do that (see Thanks for linking to your change--it gives me a place to start looking. I should have time this week to look into it more, and I'll let you know what I find. If you find any more clues, let me know! |
Cool, thanks for looking into it. Sent from a mobile phone
|
Hey @ashwinr, the monitor in 3.0 (just released) is much lighter than 2.x. We decided to start over with something much simpler, and carefully evolve it as needed. If you have a chance to run your same profiling use cases with it, I'd be very interested to see the results. Thanks! |
@ashwinr I'm gonna close this since the monitor in 3.x, at least so far, as been much better on memory. If you see the problem again in 3.x, please feel free to reopen or create a new issue. Thanks! |
Cool sounds good. Sent from a mobile phone
|
Hi. I'm seeing a very similar problem on when 3.7.7. var when = require('when');
require('when/monitor/console');
function read() {
return when.resolve().delay(0).then(function() {
callRead();
});
}
function callRead() {
read();
}
callRead(); It simulates a ReadableStream's control flow, where The code's memory usage goes up to arbitrary numbers of megabytes, until the GC kicks in. Commenting out the I see two possibilities: either the code really is leaking references to Promises, and the console monitor only brings about the demise of the process faster, or it's the monitor who is leaking something (I've only seen Promise references in Chrome inspector so far). Will keep watching the "stable" process for a few hours to determine if there is a memory leak without the monitor module, but so far, it seems there is none. |
I've been watching the process without the |
Looks like the monitor code is holding references in memory indefinitely. This is causing us to leak a lot of memory. Please look at the attached screenshot.
The text was updated successfully, but these errors were encountered: