bytecodealliance / bytecodealliance/wit-bindgen

c#: Update the allocation clean up code to avoid using closure which will allocate on the heap

Open
#1,143 1 comment 0 reactions 0 assignees View on GitHub
gen-c#
Dominant language
Rust
Stars
1.5k
Forks
286
Avg merge
6h 32m
Merged PRs (30d)
19

Description

> Also note that cleanups.Add(()=> NativeMemory.AlignedFree({address})); will allocate closure.
>
> Agree. I would consider handling this in a stack allocated `struct` that implements `IDisposable` or a `ref struct` with a `Dispose()` method. Note that Roslyn allows a `ref struct` with a `Dispose()`, not implementing `IDisposable`, to be used in a `using` statement.

_Originally posted by @AaronRobinsonMSFT in [#1012](https://github.com/bytecodealliance/wit-bindgen/issues/1012#issuecomment-2610430610)_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.