C# deallocate memory referenced by IntPtr

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

    Perhaps you could try creating a Bitmap object from hBitmap and then disposing it.

    Bitmap bitmap = Bitmap.FromHBitmap(hBitmap);
    bitmap.Dispose();
    

提交回复
热议问题