且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ImageList中/图像OutOfMemoryException异常

更新时间:2023-12-05 14:48:16

您处理图形?此外,它在处置你的形象就像你提到的,那么你就需要确保它被取出的ImageList,或者你将造成更多的问题。什么是什么格式的图像?

Are you disposing graphics? Also, it you dispose your image like you mentioned then you would need to make sure it is taken out of the ImageList or you will cause more issues. What what format are the images?

在一般来说,当你的内存不足问题图像时参与,您的问题将是要么一些方法不喜欢一些图像格式,或9/10的时候,你误解了图形对象中的一个的生命周期。

In general when you get out of memory issues when images are involved, your issue will be either some method does not like some image format, or 9/10 times, you misunderstood the lifecycle of one of the graphic objects.


  • 检查所有的图形用法并把它们放在使用块。

  • 检查图片生命周期,并小心复制它们,处理它们,收盘底层流等。

  • 加载了一个内存管理器(VS2008有一个内置),看看有什么是没有得到清理很好。

  • Check all your Graphics usage and put them in using blocks.
  • Check your Image life cycle and be careful with copying them, disposing them, closing underlying streams, etc.
  • Load up a memory manager (VS2008 has one built in) and see what is not getting cleaned up nicely.

编辑:

下面是我能找到,使用***的选择的 ImageList.Draw (图形,X,Y,宽度,高度,指数)。这将使用内部处理,而不是创建影像的副本。

Here is the best option I can find, use ImageList.Draw(graphics, x, y, width, height, index). This will use the internal handle instead of creating a copy of the image.