Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Out of Memory Exception (Read 2456 times)
roberta_gonsales
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Mar 18th, 2008
Out of Memory Exception
Apr 30th, 2008 at 7:48am
Print Post  
Hi,

I got Out of memory exception (calling HtmlBuilder.CreateImageMap ) when I try to create a diagram made of 2 empty tablenodes connected with one DiagramLink .
The problem occurs when I set the HyperLink propery of the DiagramLink . If I don't set this property I will not have the link drawn between these nodes.

The problem can be reproduced in your Webapp sample if you add the following code to a new button :


[color=Navy]protected void Button1_Click(object sender, EventArgs e)
{
Random rnd = new Random();
diagram.DefaultShape = Shapes.Rectangle;

TableNode t = diagram.Factory.CreateTableNode(0, 0, 80, 50);
t.Style = TableStyle.RoundedRectangle;
t.RowHeight = 50;
t.RowCount = 0;
t.ColumnCount = 4;
t.Caption = "aaa";
t.CaptionHeight = 30;
t.Image = new Icon(
Server.MapPath("Images\\" + "ico" + rnd.Next(4).ToString() + ".ico")).
ToBitmap();
t.ImageAlign = ImageAlign.TopLeft;
diagram.Font = new Font("Arial Hebrew", 12f,FontStyle.Bold, GraphicsUnit.Pixel);

t.ResizeToFitText(true);

TableNode t2 = diagram.Factory.CreateTableNode(0, 0, 80, 50);
t2.Style = TableStyle.RoundedRectangle;

t2.RowHeight = 50;
t2.RowCount = 0;
t2.ColumnCount = 4;
t2.Caption = "bbb";
t2.CaptionHeight = 30;
t2.Image = new Icon(
Server.MapPath("Images\\" + "ico" + rnd.Next(4).ToString() + ".ico")).
ToBitmap();
t2.ImageAlign = ImageAlign.TopLeft;
t2.ResizeToFitText(true);

DiagramLink arrow = diagram.Factory.CreateDiagramLink(t, t2);
arrow.TextStyle = LinkTextStyle.Center;
arrow.HyperLink = "www.microsoft.com";
arrow.Text = "conn = 4 " + "\n\r";



}[/color]

below the stack trace :

Server Error in '/WebApp' Application.
--------------------------------------------------------------------------------


Out of memory.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OutOfMemoryException: Out of memory.

Source Error:


Line 148: HtmlBuilder hb = new HtmlBuilder(fc);
Line 149: hb.LinkTarget = "_blank";
Line 150: return hb.CreateImageMap("map1");
Line 151: }
Line 152:


Source File: c:\Program Files\MindFusion\FlowChart.NET Trial Version\VS2005 (.NET 2.0)\Samples\C#\WebApp\MainForm.aspx.cs Line: 150

Stack Trace:


[OutOfMemoryException: Out of memory.]
System.Drawing.Drawing2D.GraphicsPath.Widen(Pen pen, Matrix matrix, Single flatness) +196329
System.Drawing.Drawing2D.GraphicsPath.Widen(Pen pen) +18
MindFusion.Diagramming.DiagramLink.x690418e55f0551ae() +281
MindFusion.Diagramming.HtmlBuilder.CreateImageMap(String mapName) +858
WebApp.MainForm.createMap() in c:\Program Files\MindFusion\FlowChart.NET Trial Version\VS2005 (.NET 2.0)\Samples\C#\WebApp\MainForm.aspx.cs:150
WebApp.MainForm.imgMap_PreRender(Object sender, EventArgs e) in c:\Program Files\MindFusion\FlowChart.NET Trial Version\VS2005 (.NET 2.0)\Samples\C#\WebApp\MainForm.aspx.cs:158
System.Web.UI.Control.OnPreRender(EventArgs e) +2117788
System.Web.UI.Control.PreRenderRecursiveInternal() +86
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041

[b]Thanks,
Roberta[/b]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Out of Memory Exception
Reply #1 - Apr 30th, 2008 at 9:02am
Print Post  
Hi,

The link's start and end points coincide because the tables are at exactly the same coordinates, the link.Length becomes 0, and it seems the GraphicsPath class does not like zero-length paths and throws the exception. Until we add some checks for this condition, set the Hyperlink only when DiagramLink.Length property returns a value larger than say 0.1.

Stoyan
  
Back to top
 
IP Logged
 
roberta_gonsales
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Mar 18th, 2008
Re: Out of Memory Exception
Reply #2 - Apr 30th, 2008 at 9:33am
Print Post  
Hi,

Thanks for the answer,

I have done this change , but in this case I don't see  the line of the arrow drawn (only it's head appers on the center of the first node)

Thanks,

Roberta
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Out of Memory Exception
Reply #3 - Apr 30th, 2008 at 9:43am
Print Post  
Yes, that's because all points of the link are at the center of the node. If you move the tables further away from each other, you will see more of the link. Or otherwise, move ControlPoint[0] and ControlPoint[ControlPoint.Count - 1] to the middles of some opposite sides of the tables, and call link.Route.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint