Skip to content

Conversation

@kring
Copy link
Member

@kring kring commented Jan 17, 2023

Fixes #17

I had hoped this would reduce garbage collector pressure and finalization overhead, but I can't actually observe any difference. That's not too surprising because we don't create and destroy native-backed objects very often, and that's the only time this will affect anything.

Still, this is the right way to do things, and could even fix an extremely rare race condition (so rare I've never seen it) where an object is garbage collected while its native code is still executing.

@kring kring merged commit cb21853 into main Jan 29, 2023
@kring kring deleted the safehandles branch January 29, 2023 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use SafeHandle instead of IntPtr for C# to hold a pointer to a C++ implementation class

2 participants