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

Managing lifetimes of [UnmanagedFunctionPointer] delegates #50

Open
TChatzigiannakis opened this issue May 18, 2016 · 1 comment
Open
Assignees

Comments

@TChatzigiannakis
Copy link
Contributor

As per the MSDN documentation, any delegate that's passed to unmanaged code as a function pointer needs to be explicitly kept alive in managed code, since the GC doesn't track pointers on the unmanaged side.

We have many such delegates in LLVMSharp. In LLVMSharp.Api, I intend to have the relevant wrapper classes manage their lifetimes so the user won't have to call GC.KeepAlive() on them. For example, a delegate that logically belongs to a Context will be kept alive privately and will be released only when the Context is Disposed.

@TChatzigiannakis TChatzigiannakis self-assigned this May 18, 2016
@mjsabby
Copy link
Contributor

mjsabby commented May 18, 2016

Sounds good. Great work on the OOApi, I'm still focusing on getting this runnable on as many platforms, so it's good we're doing non overlapping stuff.

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

No branches or pull requests

2 participants