mickhansen / dataloader-sequelize

Batching and simplification of Sequelize with facebook/dataloader
MIT License
284 stars 58 forks source link

Memory leak issues #110

Closed mschipperheyn closed 4 years ago

mschipperheyn commented 4 years ago

I have a lot of problems with memory leaking on the dataloader. This is not directly caused I think by dataloader but by the fact that we have to pass the dataloader in the context of the request and that causes many places where small mistakes can lead to references to it hanging around. Some of these issues occur through 3rd party libraries. I also have the feeling that relations between sequelize model instances has a tendency to create memory leaks.

I have been trying to kill dataloader references in my graphql (apollo) end of request event (willSendResponse), and I have made progress but it remains a difficult problem.

My thinking is that dataloader should have its own cleanup function. Calling this should loop over all loaders and empty them to minimize the risk of dangling references that hang around. What do you think?

mickhansen commented 4 years ago

The loaders should be in an LRU to be kept to a minimum, but yeah references can still be a problem of course. A cleanup function may work.

mschipperheyn commented 4 years ago

I could have a stab at that.

mickhansen commented 4 years ago

Please do, i'd also be very interested to see if there was a way we could test this in an automated way. I've only run GraphQL on lambda so memory leaks haven't really been an issue

mschipperheyn commented 4 years ago

https://github.com/mickhansen/dataloader-sequelize/pull/111

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

m-rolana commented 2 years ago

Hi! I have memory leak as well. It was solved by commenting dataloader. But it is not the way as for me. I still eager to use this library in my code. Was there any progress here #111?