Yomguithereal / baobab

JavaScript & TypeScript persistent and optionally immutable data tree with cursors.
MIT License
3.15k stars 115 forks source link

Memory leak when overwriting monkeys #478

Closed jrust closed 7 years ago

jrust commented 7 years ago

I discovered that when I overwrite the state in a tree that has monkeys the internal _monkey listener does not get removed. I could try using getMonkey or iterating through _monkeys and calling release() on each, but not sure if it would better be handled internally by baobab. I've got a plnkr where you can see the issue in the console logs: https://plnkr.co/edit/roYgMxGvE19cazQ8iyEp?p=preview

Let me know what you think is the best path forward and I can put together a PR. Thanks.

Yomguithereal commented 7 years ago

That's indeed an issue and I agree this should be better handled by baobab internally. I probably overlooked something in my code. I will gladly review a PR on the subject.