English 中文(简体)
记忆片
原标题:Picture Box out of Memory
  • 时间:2011-08-09 03:45:36
  •  标签:
  • c#
  • winforms

I am developing a windows form application. At one of my form i place a picture box control. Its working fine for majority of time. But sometime it displays red cross rather than displaying actual picture.

我进一步探讨这一问题,并了解到,这种控制处理内部例外情况。 因此,一去<代码>Debug->Exceptions,并核对相关的<代码>被抛在箱。 然后发现红箱由于以下错误而显示:

A first chance exception of type  System.OutOfMemoryException  occurred in System.Drawing.dll

Additional information: Out of memory.

是否有任何机构建议我如何处理这一例外?

最佳回答

各位评论说,你正在使用<代码>PictureBox上的多种图像。 您应“建议”dispose。 在应用新形象之前,如:

private void ChangePictureBoxImage(Image image)
{
    pictureBox.Image.Dispose();//dispose the old image.

    pictureBox.Image = image;
}
问题回答

How much RAM does your target machine have?

你之所以放弃这一例外,是因为为图像分配更多的记忆的呼吁失败。 如果你无法增加计算机的记忆量,试图缩小图像尺寸或关闭你运行的任何其他方案。





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签