Skip to content
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? #20

Open
stefansaravolac opened this issue Oct 5, 2017 · 10 comments
Open

Possible memory leak? #20

stefansaravolac opened this issue Oct 5, 2017 · 10 comments

Comments

@stefansaravolac
Copy link

Hi,

I'm using library(v1.1.1) on node 6.9.1. to retry when saving system errors to database.
For each created error, I create an instance of promise-retry, with options like this:

minTimeout= 6000;
maxTimeout= 10000;
retries= 9999999

When the error is created in the system, it is automatically saved to database.

When I try to run test code with 23 error instances to be created,
the node process breaks due to -heap out of memory-
(on the 8th instance created)

If I turn off library, and just save errors to database without retry,
all 23 errors are saved without memory leak.

I've attached stack excerpt and code I used to simulate memory leak.
It seems to be library bug. Could you please check this?

memoryTest.txt
Stack.txt

@satazor
Copy link
Member

satazor commented Nov 2, 2017

I will need a reproducible test/code so that I can debug. Are you able to attach a small zip file and instructions?

@stefansaravolac
Copy link
Author

stefansaravolac commented Nov 10, 2017

Hi. Please check memoryTest.txt for code, and Stack.txt for error, from previous post.

@lbland
Copy link

lbland commented Nov 21, 2017

any update on this?

@satazor
Copy link
Member

satazor commented Nov 22, 2017

I didn’t have time to inspect this and without any reproducible test / repo it’s hard. Usually this is a leak in your code not with this module.

@satazor
Copy link
Member

satazor commented Nov 22, 2017

Actually @stefansaravolac supplied some test code, will try to debug in the next couple of days..

@huan
Copy link

huan commented May 27, 2018

Hello, I'm planing to use this project on my server, so I want to know had this issue been confirmed or fixed?

@tcollinsworth
Copy link

tcollinsworth commented Jul 30, 2019

Experienced this multiple times and just reproduced and fixed excessive memory/GC in a service using this library.
The underlying retry library uses memory and creates garbage proportionate to the retries value.
Use a much lower value for retries and higher maxTimeout.
OR better yet
Use forever and evaluate the retry count in the loop if it's desired to quit after some number of retries.

@adams-family
Copy link

@satazor Were you able to debug it as in your comment above? Memory leak is a problem I think.

@adams-family
Copy link

For anyone who is interested, until this is resolved, I've just reverted back to (a slightly modified version of):

function retryForever(fn) {
  return fn().catch(function(err) { 
    return retryForever(fn); 
  });
}

Source: https://stackoverflow.com/questions/30471131/how-can-you-retry-after-an-exception-in-javascript-when-using-promises

@collaorodrigo7
Copy link

collaorodrigo7 commented Oct 28, 2020

We are experiencing the same problem described in this issue. We actually were not sure what was causing it until we came across this issue.
We were able to replicate following the code posted by @stefansaravolac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants