[doc/ffi] NativeFinalizer
shutdown guarantees
#55511
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
library-ffi
P3
A lower priority bug or feature request
type-documentation
A request to add or improve documentation
Currently, the documentation states that native finalizers will be run before isolate group shutdown.
The implementation currently guarantees that native finalizers are run on isolate shutdown.
Currently we under-promise, and over-deliver.
It might be useful to actually promise run on isolate shutdown. This way users using the isolate APIs can use native finalizers freeing up globals in native code and reuse that native code when a new isolate is started.
Thanks for reporting @mraleph!
@lrhn Any concerns about over-promising things?
Side note: Shared (isolate group) native finalizers
If in the future we introduce
shared
variables, we'd likely want to have a type of native finalizer that is only guaranteed to run on isolate group shutdown. For such shared native finalizers, we might need a different constructor:If we were to introduce a native finalizer shared in an isolate group with a different constructor, we'd need to update the doc comments to reflect these two different shutdown guarantees for shared and non-shared native finalizers.
The current workaround without the
shared
keyword is to useDart_FinalizableHandle
s from thedart_api.h
, these are isolate group scoped instead of isolate scoped.Edit, also see:
NativeFinalizer
s overIsolate.exit
? #55050 (comment)The text was updated successfully, but these errors were encountered: