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

Audit usages of Marshal.AllocHGlobal for ones that can be replaced with NativeMemory.Alloc #54297

Open
tannergooding opened this issue Jun 16, 2021 · 2 comments
Assignees
Labels
area-System.Runtime.InteropServices help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@tannergooding
Copy link
Member

#54006 introduced new NativeMemory APIs that wrap malloc, calloc, realloc, and aligned_alloc. We should audit existing usages of Marshal.AllocHGlobal for cases where it can be safely replaced with malloc.

Notably cases like StringToPtrHGlobal do not qualify as they are documented to be a call to LocalAlloc on Windows. However, on Unix and in cases where this is not a definitive contract, it should be safe to replace these calls with faster ones to NativeMemory.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-Interop-coreclr untriaged New issue has not been triaged by the area owner labels Jun 16, 2021
@jkotas jkotas added area-System.Runtime.InteropServices help wanted [up-for-grabs] Good issue for external contributors and removed area-Interop-coreclr labels Jun 16, 2021
@reflectronic
Copy link
Contributor

I'll take this one.

@tannergooding
Copy link
Member Author

Thanks reflectronic. Assigned out.

@tannergooding tannergooding removed the untriaged New issue has not been triaged by the area owner label Jun 18, 2021
@tannergooding tannergooding added this to the Future milestone Jun 18, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jun 21, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Runtime.InteropServices help wanted [up-for-grabs] Good issue for external contributors
Projects
Status: No status
Development

No branches or pull requests

3 participants