Jump to content
  • Advertisement
Sign in to follow this  
Greg K

[.net] Garbage Collection between a DLL?

This topic is 4954 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am calling functions in an unmanaged DLL from C#. If my function returns a string will c# garbage collect on it when it is done? And if it does, how can I make it not? Add the unsafe keyword? -Greg

Share this post


Link to post
Share on other sites
Advertisement
I think that it depends on how the string is returned. If the function returns a pointer to momory alocated within the legacy DLL than I believe that it is the DLL's responsibity to free it. If you pass a pointer to managed memory using the fixed statement that the DLL then fills the GC should collect it after the end of the fixed block and after you are done with it. Could be entirely wrong here so anyone else should feel free to correct me.

Here is a link to a part of the docs that kinda talks about this.

hope this helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!