sherpa-onnx
sherpa-onnx copied to clipboard
[Flutter] Hot release doesn't free up the RAM taken by the model
In the development, I start the Isolate.spawn with a kokoro-en-v0_19 model. After hot restarting the app, it doesn't free the memory used in the previous VM instance. It is reproducable in both Android and iOS for me. I am attaching memory charts of both platforms, and you can see the hot restart event clearly there. For every hot restart it increases by 800-900MBs, until crashed.
@dosu
This looks like a native memory leak: Flutter hot restart resets the Dart VM but doesn't guarantee cleanup of native resources, especially those allocated by isolates or native libraries like sherpa-onnx. If the model or native resources aren't explicitly disposed before a hot restart, their memory can persist and accumulate with each restart.
Check if the plugin or your code provides a way to dispose or unload the model and native resources before a hot restart. Make sure isolates are properly terminated and any native cleanup methods are called. If no explicit disposal is available, this may be a limitation of the current integration between Flutter and the native library. Testing with a minimal example can help confirm if the leak is specific to sherpa-onnx or a general native resource management issue in Flutter.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other