Flutter Memory Leak - Flutter Bloc
I managed to locate the memory leak. The cause was in fact Bloc. I was opening the camera in a modal by pushing with the navigator. The problem was that i was not pushing to this modal from a Bloc listener but rather from within the widget.
With Flutter Bloc it is recommended to perform Navigation from within a Bloc Listener.
I ended up removing the Navigation altogether and simply showed the camera widget in response to a change in state.
The change was dramatic in terms of memory usage, and the garbage collector has started behaving in a much more predictable way.
Yeah, what i was suspecting is true. You have to override the dispose method on your blocs.
Here you call checkpointBloc.dispose but you never implemented the dispos method on checkpointBloc
@override void dispose() { checkpointBloc.dispose(); super.dispose(); }
You have to override dispose method checkpointBloc doing all type of cleaning up there