搞了快一个礼拜都不解的问题,今天找到原因了。。。我都无奈了。。微软自己的问题。
原文地址:http://support.microsoft.com/kb/813967
大概翻译下:
SYMPTOMS:
When you use an ImageList class in a Microsoft Windows Forms application, the calling process will leak some GDI objects for each new instance of the ImageList class. When the number of GDI objects runs out, any later operation that requires an allocation of a new GDI object fails.
The type of failure depends on the type of operation that is requested. Typically, an OutOfMemoryException error occurs. You can view the number of GDI objects that a process uses in Windows Task Manager. To do this, click Select columns on the View menu, and then click to select the check box for GDI Objects to add the GDI objects count to the default view
大概翻译下:
症状:
当你使用ImageList类在微软的窗体中的时候,在每个包含Imagelist创建新实例中的进程将会泄露GDI对象。当GDI对象被用完,将会出现请求分配GDI对象失败
这种失败取决于操作的类型。一般会出现有OutOfMemoryException出现。您可以在 Windows 任务管理器查看一个进程使用的 GDI 对象数。要执行此操作在 视图 菜单上单击 选择列,然后单击以选中要添加到默认视图的 GDI 对象计数的 GDI 对象 对应的复选框。
后面竟然有这么一句:
Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next .NET Framework service pack that contains this fix.
因此,如果你不是被这个问题影响的很严重的话,微软推荐你耐心的等等下个版本,这个问题将会被修复。。。
我每次使用一个CImageList就会造成4个GDI的泄露,如果不玩命用的话,还是能勉强凑活的。。。