-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Out of memory Exception #278
Comments
Note that sometimes an out of memory exception is thrown by System.Graphics if trying to draw very small objects (I ran into this recently). See for example https://social.msdn.microsoft.com/Forums/vstudio/en-US/4c0aa2b2-6555-4c6f-85fc-8467e86bdf20/systemdrawinggraphicsdrawpath-throws-outofmemoryexception-when-drawing-a-very-small-cubic-bezier?forum=netfxbcl. |
path stroke-width="0.2" stroke-linecap="square" stroke-dasharray="1 0.5" d="M79.623 47.197C79.609 47.204 79.596 47.212 79.582 47.219"/ |
Looks good for me, but maybe the created structures are indeed too small. You may try to increase the difference between the coordinates in the curve part of the path just to check if this is the problem. |
Increased curve to 89 and it works ok. Only one question is how to fix that in code because I cant affect source image because it's a blueprint. |
The only possibility I see currently is to add checks in the SVG library for very small sizes (this can happen for paths and other objects) and skip the rendering in this case as a workaround for the bug in .NET drawing. Also, maybe the problem is gone with a newer .NET version? (though I doubt it) |
i am afraid this is a GDI bug... hard to tell. |
If I exclude very small size my blueprint looks pure. Only long lines are visible |
Fix in SvgVisualElements.cs resolves a problem |
I think I have read that catching this kind of exception that come from GDI does not work in release mode - but this may be wrong. Be sure that it works in release mode, though. |
There is another issue in drawing text tag when export to png. Text placement is wrong(a bit above). But whe I debug everything works ok |
We're bumping into it as well, too small paths seem to be causing it. Any chance the workaround of catching the OutOfMemoryException may make it? It would then at least render all other elements. I'm using this workaround now, but it may of course hide too much:
|
Application failes for 523KB file with exception
{"Out of memory."}
Data:{System.Collections.ListDictionaryInternal}
Looks like due to file with many tags Dictionary couldn't hold massive data
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawPath(Pen pen, GraphicsPath path)
at Svg.SvgRenderer.DrawPath(Pen pen, GraphicsPath path) in D:\SVG\SVG-master\Source\Rendering\SvgRenderer.cs:line 55
at Svg.SvgVisualElement.RenderStroke(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\Basic Shapes\SvgVisualElement.cs:line 283
at Svg.SvgPath.RenderStroke(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\Paths\SvgPath.cs:line 132
at Svg.SvgVisualElement.Render(ISvgRenderer renderer, Boolean renderFilter) in D:\SVG\SVG-master\Source\Basic Shapes\SvgVisualElement.cs:line 173
at Svg.SvgVisualElement.Render(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\Basic Shapes\SvgVisualElement.cs:line 129
at Svg.SvgElement.RenderChildren(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\SvgElement.cs:line 726
at Svg.SvgVisualElement.Render(ISvgRenderer renderer, Boolean renderFilter) in D:\SVG\SVG-master\Source\Basic Shapes\SvgVisualElement.cs:line 183
at Svg.SvgVisualElement.Render(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\Basic Shapes\SvgVisualElement.cs:line 129
at Svg.SvgElement.RenderChildren(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\SvgElement.cs:line 726
at Svg.SvgVisualElement.Render(ISvgRenderer renderer, Boolean renderFilter) in D:\SVG\SVG-master\Source\Basic Shapes\SvgVisualElement.cs:line 183
at Svg.SvgVisualElement.Render(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\Basic Shapes\SvgVisualElement.cs:line 129
at Svg.SvgElement.RenderChildren(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\SvgElement.cs:line 726
at Svg.SvgElement.Render(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\SvgElement.cs:line 714
at Svg.SvgFragment.Render(ISvgRenderer renderer) in D:\SVG\SVG-master\Source\Document Structure\SvgFragment.cs:line 169
at Svg.SvgDocument.Draw(Bitmap bitmap) in D:\SVG\SVG-master\Source\SvgDocument.cs:line 502
at Svg.SvgDocument.Draw() in D:\SVG\SVG-master\Source\SvgDocument.cs:line 466
at SVGViewer.SVGViewer.RenderSvg(SvgDocument svgDoc) in D:\SVG\SVG-master\Samples\SVGViewer\SvgViewer.cs:line 45
at SVGViewer.SVGViewer.open_Click(Object sender, EventArgs e) in D:\SVG\SVG-master\Samples\SVGViewer\SvgViewer.cs:line 28
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at SVGViewer.Program.Main() in D:\SVG\SVG-master\Samples\SVGViewer\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
The text was updated successfully, but these errors were encountered: