Welcome Guest Search | Active Topics | Sign In | Register

System.OutOfMemoryException - System.Drawing.Graphics Options
KSystems
Posted: Friday, September 13, 2024 6:40:49 PM
Rank: Advanced Member
Groups: Member

Joined: 1/15/2015
Posts: 48
Hello eo_support,

We are using EO WebBrowser WinForm version 24.1.46, and we are getting a new out of memory exception we haven't seen previously. We know that our web application has some memory leak and we are the cause of the out of memory condition. However, we normally catch and handle the ChildProcessOutOfMemoryException by listening to EO.Base.Runtime.Exception events, and we automatically recover from it (similar to how Chrome does) by creating a new instance of WebControl + WebView and the user experiences at most a random refresh of the page.

The problem is, a new exception is being thrown and caught in Application.ThreadException events at the same time when the EO.Base.ChildProcessOutOfMemoryException occurs. We can't seem to handle this, no matter what the application shuts down. Here is the error:

System.OutOfMemoryException: Out of memory.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
at System.Windows.Forms.ControlPaint.DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset)
at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle)
at System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

We believe this is from the EO.WebBrowser control. It doesn't happen every time on all PCs, I think mainly on PCs with much lower available memory experience this more. Do you know why this may be happening?
eo_support
Posted: Saturday, September 14, 2024 3:30:28 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

The stack trace you posted has nothing to do with our code. It appears that both Windows.Forms and our code run into the same problem --- out of memory. So the root of the problem is indeed that the system is low on memory, which caused both Windows.Forms and our code to fail at the same time.

There is no way you can handle and recover from an out of memory situation like this. You can only try to avoid the situation. For example, in your case your Windows.Forms control has a background image and it run out of memory while trying to paint that image. So one way that you can avoid this code path is not to use background image.

The other thing that you may want to check is whether you have some kind of restriction/policy on your system that restricts the amount of memory your application can use. If there is, you might want to increase the limit. You may want to contact your system administrator to get more details on this.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.