You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the 'Memory' tab in your browser's developer tools to watch the memory usage over time.
In the below example I see ~65,000 callbacks and ~90mb memory usage after 60 seconds.
The leak occurs when calling timeline.setGroups (or timeline.setData) with any number of groups.
The number of items does not appear to affect this, and this issue does not appear to occur simply when setting items, or redrawing, only when using either setGroups or setData to set new groups.
The issue appears to be in Group.js when registering a listener to check for ranged items:
itemSet.body.emitter.on("checkRangedItems", ...fn...) is called on all groups, ignoring whether or not the listener has already been registered on the emitter, leading to a leak of unreleased listeners.
Simply delete timeline._callers.checkRangedItems before redrawing or setting new data.
Next Steps
I'm not familiar enough with the library to comfortably submit a PR without knowing the ramifications of the change (or if there are other things that rely on this behavior), however if it will greatly increase the speed of getting this fixed and merged, then perhaps I can spend some time over the next week to create a suitable patch.
Please let me know if you have any other questions, if there is trouble reproducing, or if I need to provide any other details.
Thanks,
Aphix
The text was updated successfully, but these errors were encountered:
Are there any plans to have it fixed in one of the upcoming releases? If not, is there any way to apply the mentioned workaround if I am using ngx-vis?
This is my attempt at solving #183.
There are two key differences when compared to #235:
1. This one actually works better.
2. This one doesn't blindly throw away all listeners.
Leaks in my tests (very rough measurements on my device):
- Upstream: 3 MB/s
- #235: 250 KB/s
- This: about 0 KB/s
PS: For the tests I used the JSFiddle MWE from @aphix. I just decreased
delays to leak more memory in shorter amount of time.
* fix(item-set): don't leak memory when setting groups
This is my attempt at solving #183.
There are two key differences when compared to #235:
1. This one actually works better.
2. This one doesn't blindly throw away all listeners.
Leaks in my tests (very rough measurements on my device):
- Upstream: 3 MB/s
- #235: 250 KB/s
- This: about 0 KB/s
PS: For the tests I used the JSFiddle MWE from @aphix. I just decreased
delays to leak more memory in shorter amount of time.
* style(groups): fix spelling etc. in a comment
Fiddle/Example
Use the 'Memory' tab in your browser's developer tools to watch the memory usage over time.
In the below example I see ~65,000 callbacks and ~90mb memory usage after 60 seconds.
Here's a complete JS Fiddle demonstrating the leak.
Line 52 is causing the leak in the above example.
Description/Analysis
The leak occurs when calling
timeline.setGroups
(ortimeline.setData
) with any number of groups.The number of items does not appear to affect this, and this issue does not appear to occur simply when setting items, or redrawing, only when using either setGroups or setData to set new groups.
The issue appears to be in
Group.js
when registering a listener to check for ranged items:itemSet.body.emitter.on("checkRangedItems", ...fn...)
is called on all groups, ignoring whether or not the listener has already been registered on the emitter, leading to a leak of unreleased listeners.In current revision: Group.js, lines 85-87
This bug was introduced 5 years ago in this commit
Hacky Workaround
Simply
delete timeline._callers.checkRangedItems
before redrawing or setting new data.Next Steps
I'm not familiar enough with the library to comfortably submit a PR without knowing the ramifications of the change (or if there are other things that rely on this behavior), however if it will greatly increase the speed of getting this fixed and merged, then perhaps I can spend some time over the next week to create a suitable patch.
Please let me know if you have any other questions, if there is trouble reproducing, or if I need to provide any other details.
Thanks,
Aphix
The text was updated successfully, but these errors were encountered: