Question on getting arrays from unmanaged dlls

I have a dll written in C that returns a float* (float array) and in C# I am able to grab that array like so:

//declare private static extern float [] getdata(); //use float[] data = getData(); 

That works, in unsafe mode. great. but normally you would need to call back to the dll when you are done with the data and tell it to free the memory, and I can't seem to do that. This doesn't work:


Does the array become a managed garbage collected array when I get it? Is there some way to free it without going into unsafe mode?

by jackmott via /r/csharp

Leave a Reply