dispose method

void dispose()

Releases all TensorFlow Lite resources held by this model.

Call this when you're done using the segmentation model to free up memory. After calling dispose, this instance cannot be used for inference.

It is safe to call dispose multiple times.

Important: If you are switching models (disposing one and immediately creating another), prefer disposeAsync which ensures the background isolate is fully terminated before freeing the native interpreter.

Implementation

void dispose() {
  if (_disposed) return;
  _compiledModel?.close();
  _doDispose();
}