If a dynamic array is allocated with
intPtr = new int[1234];
in c++ and the data is subsequently marshaled to a managed C# array, is it valid to free the originally allocated memory on the managed side using
Marshal.FreeHGlobal()
or will this leak memory?
If this does leak memory, is there another method that can be used on the managed side to cleanly free the memory or is it necessary to implement the freeing code on the native side and pass a callback function to the managed side?
Thanks!