Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Memory management for Blocks #429

Merged
merged 8 commits into from
Jul 28, 2022
Merged

Memory management for Blocks #429

merged 8 commits into from
Jul 28, 2022

Conversation

liamappelbe
Copy link
Contributor

Add a copy/release finalizer for blocks, same as we have for NSObjects. Automatically cleans up the native memory associated with Blocks.

This implements all but the last dot point from dart-lang/native#233. Note that this still leaks the Dart Function objects (see dart-lang/native#233)

Fixes dart-lang/native#233. Filed a separate issue (#428) for cleaning up the Dart Functions, since that's not going to happen any time soon.

Copy link
Contributor

@brianquinlan brianquinlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to just let blocks leak if it is a hack to clean them up?

@liamappelbe
Copy link
Contributor Author

Would it make sense to just let blocks leak if it is a hack to clean them up?

The way I'm cleaning up blocks in this PR is not a hack. The only hack is in the test that checks the refcount.

The Dart Function objects associated with ObjCBlock.fromFunction are still leaked, because I wasn't able to clean them up, with or without hacks.

@brianquinlan
Copy link
Contributor

Sorry, I misunderstood then.

@liamappelbe liamappelbe merged commit ba760e1 into master Jul 28, 2022
@liamappelbe liamappelbe deleted the block_mem branch September 27, 2022 19:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Memory management for blocks
2 participants