Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jsturtevant opened this issue Jan 24, 2025 · 0 comments
Labels
gen-c# Related to the C# code generator

Comments

@jsturtevant
Copy link
Collaborator

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

@jsturtevant jsturtevant added the gen-c# Related to the C# code generator label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gen-c# Related to the C# code generator
Projects
None yet
Development

No branches or pull requests

1 participant