dispose method

Future<void> dispose()

Releases all resources used by the detector.

Implementation

Future<void> dispose() async {
  final worker = _worker;
  _worker = null;
  if (worker == null) return;

  // Graceful shutdown via the shared base: sends 'dispose' as an RPC and
  // awaits the ack before force-killing the isolate, so it can free its
  // native TFLite interpreters (~10-26MB/detector on Android) instead of
  // being reaped mid-cleanup by Isolate.kill(priority: immediate).
  await worker.disposeGracefully();
}