Bitmap.Save, Huge Memory Leak

前端 未结 5 1170
情歌与酒
情歌与酒 2021-01-16 05:02

I have an application where I am taking a bitmap and compressing it using a GZipStream and sending it over a socket, all in memory. I have tracked down the dirty scumbag mem

5条回答
  •  轮回少年
    2021-01-16 05:39

    You should set the bitmap to null when done working with it, after disposal.

    Also, you may want to invoke the Garbage Collector after disposal of the Bitmap (even though it is an expensive operation): GC.Collect();

    Bitmap holds unmanaged resources - the GC is not always "on the ball" with these. Here is an interesting link regarding the Bitmap class (from the perspective of the compact framework): http://blog.opennetcf.com/ctacke/PermaLink,guid,987041fc-2e13-4bab-930a-f79021225b74.aspx

提交回复
热议问题