wit-bindgen
wit-bindgen copied to clipboard
c#: Update the allocation clean up code to avoid using closure which will allocate on the heap
Also note that cleanups.Add(()=> NativeMemory.AlignedFree({address})); will allocate closure.
Agree. I would consider handling this in a stack allocated
structthat implementsIDisposableor aref structwith aDispose()method. Note that Roslyn allows aref structwith aDispose(), not implementingIDisposable, to be used in ausingstatement.
Originally posted by @AaronRobinsonMSFT in #1012
for some more possible design options: https://github.com/bytecodealliance/wit-bindgen/pull/1145#discussion_r1937031162