0

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) 
9
  • Are you making any Bitmap object and processing the same ? if so i believe there is not enough memory available for the process to perform the same Commented May 10, 2011 at 7:54
  • Are you disposing of all unmanaged resources? Commented May 10, 2011 at 7:56
  • 1
    @Maanu, in the other question you mentioned that you were loading 30 screens at startup. Why not include this information again? This is almost certainly the cause of the error... Commented May 10, 2011 at 8:14
  • 2
    Funny title: "Memory out of exception" :-) Shouldn't it be "Out of memory exception"? Commented May 10, 2011 at 8:39
  • 1
    @ScruffyDuck from personal experience, I'd be amazed if running out of memory when using GDI actually threw a proper OutOfMemoryException. I did quite a bit of work with large image files a while back, and not once did I see OOM thrown, even when trying to grab 1GB of memory for a single image. GDI's error reporting is comedic at best. Commented May 10, 2011 at 8:45

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.