This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
ObjCBlock.fromFunction
is passed in the same function multiple times, return a newObjCBlock
that wraps the same underlying block struct. Explicitly retain (increase ref count) of the block struct in this case. This helps reduce the leak caused by dart-lang/native#204 by reducing the number of blocks created if the user accidentally creates many blocks from the same function.This is accomplished by sticking the block struct pointer in an
Expando
(_funcToBlock
), with the Dart function as the key.I also tried sticking the
ObjCBlock
directly in_funcToBlock
, which was simpler and cleaner, but this caused theObjCBlock
to never be GC'd, because the Dart function is reachable via the_ObjCBlock_closureRegistry
. We can try refactoring this to put theObjCBlock
in the_funcToBlock
once dart-lang/native#204 is fixed.Fixes dart-lang/native#226