New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leaking with changing spot list #1106
Comments
I’m pretty sure it’s because of the static cache as I said here. |
It might be the case I didn't look too much into this since I managed to find a workaround. |
Sorry I’m on holidays and I don’t have the time nor the device to check this but could you retry your example having the memory leak but with calling a clear cache on the LineChartHelper each time you change the data values. |
add `isEnableCache` option, fix memory lake on dynamic line chart imaNNeo#1106
Dear @imaNNeo |
Fixed in the |
Fixed in 0.66.1, please test and let me know if the issue is fixed. Thanks for your patience! |
Thank you dear @imaNNeo |
I'm using lineChartData, but I'm getting a Platform_enviroment error after upgrading the version. The platform currently used is web. |
This is another issue related to #1565 |
Guys, this memory issue should be resolved on 0.66.1. Can you please validate it in your apps? |
Describe the bug
When chaning the complete FLSpot list instance/reference e.g. calculating it based on another list whenever the list changes the
LineChart
is leaking a ton ofFlSpots
Here is a DevTool-measurement within seconds the Spots grows to 100k+ instances ( Example code used to measure can be found below)
To Reproduce
To debug the behavior I had a look at the Sample#10 which does not leak any memory. However, I edited and also managed to reproduce the FLSpot leaking I encountered in my own app.
Instead of using an instance of
final sinePoints=<FlSpot>[]
(src) I am using afinal sinPoints = <double>[];
list which I later map toFlSpots
using the_convertToPlotSpots
method.Also to verify that the issue is caused by the chart I replaced the
LineChart
widget with anText('Test:${_convertToPlotSpots(sinPoints).last.x}');
widget that uses also the FlSpot list just to see if the leaking is caused by the code in_convertToPlotSpots
which is not the case.Finaly I found a workaround for me by using a single instance of
List<FlSpot>
that does not change/only swapps elements using this code for the_convertToPlotSpots
method:Sample#10 leaking Memory:
Flutter 3.0.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 676cefaaff (5 weeks ago) • 2022-06-22 11:34:49 -0700
Engine • revision ffe7b86a1e
Tools • Dart 2.17.5 • DevTools 2.12.2
fl_chart: ^0.55.0
The text was updated successfully, but these errors were encountered: