OutOfMemory Exception During Paint


I have an application that allows users to create objects on the diagram. Often during dragging of a new object, an exception is thrown that crashes the application. It seems that the LinearGradientBrush constructor is used within GoDiagram code and the crash occurs if/when the two points are the same. Below is a stack trace:

System.Drawing.dll!System.Drawing.Drawing2D.LinearGradientBrush.LinearGradientBrush(System.Drawing.PointF point1, System.Drawing.PointF point2, System.Drawing.Color color1, System.Drawing.Color color2) + 0xc3 bytes
Northwoods.Go.dll!Northwoods.Go.GoShape.GoBrushInfo.GetBrush(object shapeorpath) + 0x8e1 bytes
Northwoods.Go.dll!Northwoods.Go.GoShape.Brush.get() + 0x57 bytes
Northwoods.Go.dll!Northwoods.Go.GoShape.PaintPath(System.Drawing.Graphics g, Northwoods.Go.GoView view, System.Drawing.Drawing2D.GraphicsPath path) + 0x62 bytes
Northwoods.Go.dll!Northwoods.Go.GoRoundedRectangle.Paint(System.Drawing.Graphics g, Northwoods.Go.GoView view) + 0x73 bytes
Northwoods.Go.dll!Northwoods.Go.GoLayer.Paint(System.Drawing.Graphics g, Northwoods.Go.GoView view, System.Drawing.RectangleF clipRect) + 0x362 bytes
Northwoods.Go.dll!Northwoods.Go.GoView.PaintObjects(bool doc, bool view, System.Drawing.Graphics g, System.Drawing.RectangleF clipRect) + 0x10a bytes
Northwoods.Go.dll!Northwoods.Go.GoView.PaintView(System.Drawing.Graphics g, System.Drawing.RectangleF clipRect) + 0x219 bytes
Northwoods.Go.dll!Northwoods.Go.GoView.onPaintCanvas(System.Windows.Forms.PaintEventArgs evt) + 0x5e8 bytes
Northwoods.Go.dll!Northwoods.Go.GoView.OnPaint(System.Windows.Forms.PaintEventArgs evt) + 0x53 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs e, short layer) + 0x7c bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WmPaint(ref System.Windows.Forms.Message m) + 0x3c0 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x54a bytes
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) + 0x85 bytes

Is this something that should be fixed in the GoDiagram code or should I seek to try and prevent the situation that leads to this happening?



We exchanged email a couple of months ago about this. As I recall, the problem goes away if you don’t use gradients. But I think the underlying problem was your custom Subgraph code, and I advised you to go back and the Boxarea.vb class in NodeLinkDemo.