C# deallocate memory referenced by IntPtr

后端 未结 6 459
广开言路
广开言路 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:58

    It depends. Do you have any documentation (or source code) for the native functions you are calling?

    Native code doesn't have a single deallocation function. This is one of the great advantages of the CLR.

    If I was a betting man, I'd go for GlobalFree. But it's not going to be much fun trying various APIs until your code stops crashing.

提交回复
热议问题