C# deallocate memory referenced by IntPtr

后端 未结 6 505
广开言路
广开言路 2021-01-11 19:05

I am using some unmanaged code that is returning pointers (IntPtr) to large image objects. I use the references but after I am finished with the images, I need to free that

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-11 19:57

    Please show your unmanaged code. There are different ways to allocate memory in unmanaged land, and you must use the correct corresponding means of deallocating. You will probably end up implementing a Finalizer and IDisposable, and implementing the Dispose pattern as described here: http://www.codeproject.com/KB/cs/idisposable.aspx

提交回复
热议问题