wnr / element-resize-detector

Optimized cross-browser resize listener for elements.
MIT License
1.32k stars 118 forks source link

Memory Leak #90

Closed GlennGeenen closed 6 years ago

GlennGeenen commented 6 years ago

The react-sizeme component uses this package. It creates a resizeDetector singleton. The problem that we experience is that the resizeDetector retains memory (both dom elements and listeners). The component calls removeAllListeners in componentWillUnmount what seems like the correct approach.

I have create an issue in react-sizeme with a solution (https://github.com/ctrlplusb/react-sizeme/issues/131) but I'm not convinced the issue is within the react-sizeme package.

wnr commented 6 years ago

Hi, I believe you should call uninstall rather. The removeAllListeners still keeps the detection system of the element for fast listener attachments in the future. This will retain memory.

wnr commented 6 years ago

Let's reopen the issue if it doesn't solve the issue for you :)

ctrlplusb commented 6 years ago

Brilliant! Thanks for this insight @wnr 👍

Oh, and huge love to you again for this amazing library 😘

wnr commented 6 years ago

Thanks ❤️