Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript event listener memory leak

I'm working on a WebGL application using React, Redux and Three.js. My application uses mouse movements and clicks as input. Now for some reason, whenever I click or move the mouse, my application gets slower and slower. As shown in the performance profile below, there seems to be some kind of memory leak causing the memory used by event listeners to constantly grow.

enter image description here

As far as I understand, the yellow line in the screenshot shows the constantly growing memory usage for event listeners.

But what exactly does this yellow line represent? Is it the amount of memory used by event listeners? Or the number of registered listeners? Or the number of registered/unhandled events?

Has anybody experienced a similar problem in the past and maybe found the solution?

The full code of my application/prototype can be found in this repository. Unfortunately I haven't been able yet to isolate the cause of the issue or to reproduce it in a simple code snippet.

like image 889
lsgng Avatar asked Feb 03 '26 05:02

lsgng


1 Answers

This may actually be a Dev only issue. If you build the react project with NODE_ENV=production This issue may not persist.

This appears to be related to an open issue on react at: https://github.com/facebook/react/issues/12141

like image 76
kevzettler Avatar answered Feb 05 '26 22:02

kevzettler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!