Skip to content

Curious about implementing deallocators for buffer returned from Rust #718

Answered by fzyzcjy
hsfzxjy asked this question in Q&A
Discussion options

You must be logged in to vote

if there's any approach to automatically do the deallocation job by, for example, calling a Rust deallocator function when the Dart object is about to be GCed, or I must manually call the deallocator by myself?

If you say ZeroCopyBuffer<Vec<u8>>, then it is auto deallocated when Dart decides to dispose it. Details can be found in allo-isolate, which is a wrapper around Dart's C api.

if you say any arbitrary data, they are copied (instead of zero-copy) to Flutter, and it is still Flutter's job to deallocate.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by hsfzxjy
Comment options

You must be logged in to vote
3 replies
@fzyzcjy
Comment options

@hsfzxjy
Comment options

@fzyzcjy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants