Maanu
Maanu

Reputation: 5203

Out of memory exception

I am getting out of memory exception occasionally during program startup. The stacktrace is given below. I am getting this crash only at customer machine.

What steps should I follow to identify the root cause?

[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) 

Upvotes: 0

Views: 1433

Answers (2)

bottlenecked
bottlenecked

Reputation: 2157

From the trace above I understand you are using windows.forms. Mem leaks in windows forms programs may be due to forgetting to unsubscribe events on closing the form (subscribers preventing disposing of form). There are a few articles and tutorials that suggest that this is a pretty common error in forms programming, so may be you could check it out. Of course having said that, it may not quite fit with your case (out of mem occuring in program startup).

If the memory leak occurs in managed code, using a memory profiler is probably a good idea. I mostly used the ANTS Mem Profiler, it has nice graphs and statistics and a friendlier UI in general than most.

If however the leak occurs in unmanaged code (like for this guy here) you are in for a ride. This article may be of help getting you started.

All in all you may have a lot of reading ahead trying to understand memory management in .net applications, how the gc generations work etc., and all this can eat up a lot of your time.

Good luck!

Upvotes: 0

jeroenh
jeroenh

Reputation: 26792

use a decent memory profiler to help find the root cause of the issue

Upvotes: 2

Related Questions