Skip to content

Commit c521dd6

Browse files
Kill isolate once done with it.
1 parent 0c9d30f commit c521dd6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

objectbox/lib/src/native/store.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ class Store {
389389
queriesCaseSensitiveDefault: isoPass.queriesCaseSensitiveDefault);
390390
final result = await isoPass.runFn(store);
391391
store.close();
392-
// Note: maybe replace with Isolate.exit once min Dart SDK 2.15.
392+
// Note: maybe replace with Isolate.exit (and remove kill call in
393+
// runIsolated) once min Dart SDK 2.15.
393394
isoPass.resultPort?.send(result);
394395
}
395396

@@ -402,7 +403,7 @@ class Store {
402403
TxMode mode, FutureOr<R> Function(Store, P) callback, P param) async {
403404
final resultPort = ReceivePort();
404405
// Await isolate spawn to avoid waiting forever if it fails to spawn.
405-
await Isolate.spawn(
406+
final isolate = await Isolate.spawn(
406407
_callFunctionWithStoreInIsolate,
407408
_IsoPass(_defs, directoryPath, _queriesCaseSensitiveDefault,
408409
resultPort.sendPort, callback, param));
@@ -413,6 +414,7 @@ class Store {
413414
});
414415
await result.future;
415416
resultPort.close();
417+
isolate.kill();
416418
return result.future;
417419
}
418420

0 commit comments

Comments
 (0)