-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Possible memory leak with Promise.each #1057
Comments
I've noticed, that second snippet is also leaking memory when long stack traces are enabled. Is this desired behaviour? |
@tdzienniak this is because each is currently implemented through mapSeries https://github.com/petkaantonov/bluebird/blob/master/src/each.js#L14-L17 - the behavior of Note that this is not a memory leak - it is merely wasteful behavior. |
We can implement directly with Lines 164 to 166 in 283412e
|
@benjamingr yes, I've noticed that it is implemented through mapSeries, which is why with conjunction with long stack traces is wasting a lot of memory. I spent a lot of time trying to figure out why my node process is running out of memory. Maybe a note in the docs describing this behaviour will be helpful for others? And well, this in not memory leak per se, but in context of desired |
Ping @petkaantonov |
@benjamingr feel free to give a shot at fixing it |
@tdzienniak if you feel like it - I would appreciate it if you take a look at the code with the fix and see if it fixes the issue for you. |
@benjamingr ok, I can test the examples from my initial post. |
I'm using bluebird v3.3.4 running on node v4.4.0. Leaky code:
Not leaky code:
It seems that the results of the promises are stored somewhere, but they shouldn't be, at least this is what I understand reading the docs of
Promise.each
:Issue is happening on earlier versions of bluebird too.
The text was updated successfully, but these errors were encountered: