Describe the bug
After adding the leak_tracker_flutter_testing dependency to the dev dependencies to detect memory leaks while running the tests. I found two memory leaks that happens multiple times in different tests. They are not disposed objects as listed below:
- PanGestureRecognizer object in
render_base_chart.dart file
- TapGestureRecognizer object in
render_base_chart.dart file
- LongPressGestureRecognizer object in
render_base_chart.dart file
The above memory leaks can be fixed easily just by disposing them in the detach method like below:
@override
void detach() {
_validForMouseTracker = false;
panGestureRecognizer.dispose();
tapGestureRecognizer.dispose();
longPressGestureRecognizer.dispose();
super.detach();
}
Furthermore, it has some other memory leaks, which are hard for me to fix as I'm not very familiar with the source code architecture.
- TransformationController in
axis_chart_scaffold_widget.dart file.
- TransformationController in
custom_interactive_viewer.dart file.
To Reproduce
- Add
leak_tracker_flutter_testing to the dev dependancies
dev_dependencies:
...
leak_tracker_flutter_testing: any
- Create
flutter_test_config.dart file in the root of the test folder
import 'dart:async';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
Future<void> testExecutable(FutureOr<void> Function() testMain) async {
LeakTesting.enable();
LeakTesting.settings = LeakTesting.settings
.withIgnored(createdByTestHelpers: true);
await testMain();
}
- run tests to see detected memory leaks.
Screenshots
If applicable, add screenshots, or videoshots to help explain your problem.
Versions
- Flutter Version: 3.35.1
- FlChart Version: 1.0.0
I want to create a pull request to fix those memory leaks, but I can't fix the TransformationController leaks unless you help me.
Describe the bug
After adding the
leak_tracker_flutter_testingdependency to the dev dependencies to detect memory leaks while running the tests. I found two memory leaks that happens multiple times in different tests. They are not disposed objects as listed below:render_base_chart.dartfilerender_base_chart.dartfilerender_base_chart.dartfileThe above memory leaks can be fixed easily just by disposing them in the
detachmethod like below:Furthermore, it has some other memory leaks, which are hard for me to fix as I'm not very familiar with the source code architecture.
axis_chart_scaffold_widget.dartfile.custom_interactive_viewer.dartfile.To Reproduce
leak_tracker_flutter_testingto the dev dependanciesflutter_test_config.dartfile in the root of the test folderScreenshots
If applicable, add screenshots, or videoshots to help explain your problem.
Versions
I want to create a pull request to fix those memory leaks, but I can't fix the
TransformationControllerleaks unless you help me.