sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.68k stars 642 forks source link

Bitmap memory leak in C# #1105

Closed yanchao12122 closed 5 years ago

yanchao12122 commented 5 years ago

if I put the following code in a while loop, the memory will increase all the time.

D2D.PixelFormat pixelFormat = new D2D.PixelFormat(DXGI.Format.B8G8R8A8_UNorm, D2D.AlphaMode.Premultiplied);
D2D.BitmapProperties bp = new D2D.BitmapProperties(pixelFormat,96,96);
using (D2D.Bitmap tempBitmap = new D2D.Bitmap(_RenderTarget, new DX.Size2(96, 96), bp))
{
}
xoofx commented 5 years ago

I'm pretty sure that you will get the same behavior in C++. The resources are not necessarily disposed on the release of it. The underlying device/rendertarget can keep them around and dispose them later (on a device flush or whatever is equivalent in d2d)