phetsims / axon

Axon provides powerful and concise models for interactive simulations, based on observable Properties and related patterns.
MIT License
11 stars 8 forks source link

Measuring maximum listener counts (and erroring out) for memory leak detection #407

Closed jonathanolson closed 2 years ago

jonathanolson commented 2 years ago

I'm adding a ?listenerLimit query parameter, which (when assertions are enabled) should be able to help track down common memory leaks. I've run into this many times (I usually hack in code temporarily into TinyEmitter, then remove it), so it will be a very helpful permanent feature for me.

If you set ?listenerLimit=2000, when the 2001st listener is added to ANY TinyEmitter (e.g. Property, etc.), it will error out. It will also console.log incoming maximums, so that you can quickly tell if a leak is likely.

Putting on dev board for a PSA.

zepumph commented 2 years ago

There was a PSA at dev meeting today. @chrisklus and @samreid are out today. Please unassign yourself when you have ready this, and last person feel free to close.

chrisklus commented 2 years ago

PSA received, closing!