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

Memory leak detected. #18

Open
pmiotto opened this issue May 6, 2019 · 10 comments
Open

Memory leak detected. #18

pmiotto opened this issue May 6, 2019 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed need feedback

Comments

@pmiotto
Copy link

pmiotto commented May 6, 2019

Hi.
It seems that when uploading an image with multiple resizes causes memory leaks under a small load. I've performed a load test using this library and it fails around 15 concurrent requests. Here's the error stack. Any help would be appreciated.

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:247:17)
at Sharp.addListener (events.js:263:10)
at Sharp.Readable.on (_stream_readable.js:800:35)
at ManagedUpload.send (/Users/me/Documents/wip/project/node_modules/aws-sdk/lib/s3/managed_upload.js:185:11)
at /Users/me/Documents/wip/project/node_modules/aws-sdk/lib/util.js:798:25
at new WrappedPromise (/Users/me/Documents/wip/project/node_modules/async-listener/es6-wrapped-promise.js:13:18)
at ManagedUpload.promise (/Users/me/Documents/wip/project/node_modules/aws-sdk/lib/util.js:797:14)
at MergeMapSubscriber.sizes.pipe.operators_1.mergeMap [as project] (/Users/me/Documents/wip/project/node_modules/multer-sharp-s3/dist/main.js:113:52)
at MergeMapSubscriber._tryNext (/Users/me/Documents/wip/project/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
at MergeMapSubscriber._next (/Users/me/Documents/wip/project/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
at MergeMapSubscriber.Subscriber.next (/Users/me/Documents/wip/project/node_modules/rxjs/internal/Subscriber.js:66:18)
at MergeMapSubscriber.notifyNext (/Users/me/Documents/wip/project/node_modules/rxjs/internal/operators/mergeMap.js:92:26)
at InnerSubscriber._next (/Users/me/Documents/wip/project/node_modules/rxjs/internal/InnerSubscriber.js:28:21)
at InnerSubscriber.Subscriber.next (/Users/me/Documents/wip/project/node_modules/rxjs/internal/Subscriber.js:66:18)
at /Users/me/Documents/wip/project/node_modules/rxjs/internal/util/subscribeToPromise.js:7:24
at propagateAslWrapper (/Users/me/Documents/wip/project/node_modules/async-listener/index.js:504:23)
at /Users/me/Documents/wip/project/node_modules/async-listener/glue.js:188:31
at /Users/me/Documents/wip/project/node_modules/async-listener/index.js:541:70
at /Users/me/Documents/wip/project/node_modules/async-listener/glue.js:188:31

@ikhsanalatsary
Copy link
Owner

Hi @pmiotto thanks for reporting this. how to reproduce like that?

@pmiotto
Copy link
Author

pmiotto commented May 9, 2019

HI @ikhsanalatsary. I've got an endpoint which uploads an image and a couple of resizes to S3, you can use a tool like jMeter to perform a loadtest. It fails under 10 concurrent requests. Not only I get this memory leak but some images uploaded to S3 are 0kb.

@ikhsanalatsary
Copy link
Owner

@pmiotto could you share your JMeter configuration?

ikhsanalatsary added a commit that referenced this issue May 20, 2019
@ikhsanalatsary
Copy link
Owner

ikhsanalatsary commented May 20, 2019

My configuration
Screen Shot 2019-05-20 at 10 41 59
and sometimes one image is still uploaded 0 Bytes but at least it reduces the total from previous.
So, You can try again in this branch https://github.com/ikhsanalatsary/multer-sharp-s3/tree/fix/bumps-version
PS: I need feedback. thanks

@ikhsanalatsary ikhsanalatsary added bug Something isn't working help wanted Extra attention is needed need feedback labels May 20, 2019
@mohmmadmoussa1988
Copy link

Hello Dear,

Any solution for this case ?

@Milad
Copy link

Milad commented Apr 27, 2020

This is expected to happen because you have many unused variables. Start by eliminating the unused variables from your code.

@djuko
Copy link

djuko commented Jul 22, 2020

I am also having this issue. It is because I am having a long resize set. Is there a way to do this in a way of asynchronous calls (Promisse.all or something like that) to relieve the EventEmitter ?

@djuko
Copy link

djuko commented Jul 22, 2020

I have increased for now the event emitter with require('events').EventEmitter.defaultMaxListeners = 40, but this should be heavily avoided. I suggest we find a way to implement async await when uploading multiple images. I'll follow up on this if I find a way and let you guys know :)

@Milad
Copy link

Milad commented Jul 22, 2020

Of course it can be promisified easily, and if not, then it should!

@djuko
Copy link

djuko commented Jul 22, 2020

I agree it should be promisified. I'll take a look at the src code after working hours, it would be best to implement it there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed need feedback
Projects
None yet
Development

No branches or pull requests

5 participants