C# Image.Clone Out of Memory Exception

前端 未结 6 728
礼貌的吻别
礼貌的吻别 2020-11-28 11:15

Why am I getting an out of memory exception?

So this dies in C# on the first time through:

splitBitmaps.Add(neededImage.Clone(rectDimensions, neededI

6条回答
  •  爱一瞬间的悲伤
    2020-11-28 11:37

    This is a reach, but I've often found that if pulling images directly from disk that it's better to copy them to a new bitmap and dispose of the disk-bound image. I've seen great improvement in memory consumption when doing so.

    Dave M. is on the money too... make sure to dispose when finished.

提交回复
热议问题