mrx-flutter-charts icon indicating copy to clipboard operation
mrx-flutter-charts copied to clipboard

Fixing Memory leaks for Animations

Open knusperkrone opened this issue 2 years ago • 0 comments

Thanks for this library. The current version holds 3 memory leaks tho.

  1. Chart::dispose Neither the current widget layers, nor the old layers are disposed by the regular lifecycle events. This may not be a problem, as all memory is most likely is to be freed, when the AnimationController dispose is called- but you never know.

  2. ChartLineDataItem::dispose You forgot to call dispose the touch events.

  3. Chart::didUpdateWidget When calling setState and start the animation you forget to dispose those CurvedAnimations, which then are registered on the AnimationHandler. Also, setting the _animation member to null is basically a no-op, as need to dispose the animation. I have included a screenshot where you can easily see the insane big amount of closures held by the AnimationController. The leaking observer, then has to update for too many listeners resulting in poor performance.

Screenshot 2023-02-16 at 00 57 10

knusperkrone avatar Feb 16 '23 00:02 knusperkrone