Hi community,
I attached an example which demonstates the following scenario:
1. I have an observable array
2. Each item placed into this array has a computed observable dependent on a long-living "external" observable (which bevaves like an app-wide option)
3. Due to a specific of my task, I repeatedly add and remove items to / from the array
Problem: items are not disposed automatically, because the external observable is alive. This results in memory leaks: constant growth of ko.subscription objects.
The attached artificial example leaks about 8 MB per second.
NOTE:
I understand that in this specific case I can manually dispose the dependent observable when I remove it from the array.
But in real-world and less obvious cases it can bcome a huge problem which is very hard to debug.
So do you have any recommendations?
Should we avoid using observables from long-living scopes inside ko.computed?
Shouldn't you warn users in the documentation?