内存不足异常 - c#

程序启动期间,有时会出现内存不足异常。下面给出了堆栈跟踪。我仅在客户计算机上遇到此崩溃。

我应遵循哪些步骤来确定根本原因?

[369][4/29/2011 18:32:15:343]-ERR -[ThreadId = 7916, UIFramework_ICEVisionPro_GUIExceptionHandler.LogException]-System.OutOfMemoryException: Out of memory.

   at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)

   at System.Drawing.BufferedGraphicsContext.CreateBuffer(IntPtr src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)

   at System.Drawing.BufferedGraphicsContext.AllocBuffer(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)

   at System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)

   at System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC, Rectangle targetRectangle)

   at System.Windows.Forms.Control.WmPaint(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

   at System.Windows.Forms.ContainerControl.WndProc(Message& m)

   at System.Windows.Forms.UserControl.WndProc(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 

参考方案

使用体面的内存探查器来帮助找到问题的根本原因

HttpClient.getAsync()内存不足异常 - c#

我有一个从Web服务获取大量JSON的函数。这些数据有时可能很大,千兆字节。我的电话看起来像这样。 try { using (var httpClient = NewHttpClient()) { var response = httpClient.GetAsync(endpoint).Result; return response; } } catch(E…

System.Text.Json合并两个对象 - c#

是否可以用System.Text.Json?合并两个这样的json对象对象1{ id: 1 william: "shakespeare" } 对象2{ william: "dafoe" foo: "bar" } 结果对象{ id: 1 william: "dafoe" foo: …

System.IdentityModel.Selectors.UserNamePasswordValidator不存在 - c#

Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想改善这个问题吗?更新问题,以使溢出。 6年前关闭。 on-topic 我试图从System.IdentityModel.Selectors.UserNamePasswordValidator派生一个类。但是,如果我…

C#无法将类型为“ System.Double”的对象转换为类型为“ System.Single” - c#

在判断此问题已得到回答之前,请阅读说明。我在下面有这个简单的代码:Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("key" , 30d); System.Diagnostics.Debug.WriteLine($…

错误:无法将类型为“ System.Int32”的对象转换为类型为“ System.String”的对象 - c#

我已经完成了完美的编码注册页面,登录代码,现在UpdateCustomer页面有错误-背景信息:我正在使用Microsoft Access作为数据源 LabelState.Text = (string)Session["sState"]; LabelPostalCode.Text = (string)Session["sPost…