DrawPath(Pen,GraphisPath) is throwing OutOfMemoryException
I've been over this for a couple of time and can't figure it out. the method DrawPath is throwing a Sys开发者_如何转开发tem.OutOfMemoryException.
I've seen that the pen.DashPattern is actually throwing System.OutOfMemoryException as well, so I set the dash pattern, but correcting that didn't prevent the error.
using (var pen = new Pen(Color.Black,1.0f))
{
pen.DashPattern = new[]{1.0f};
pen.Transform = context.ReverseTransform;
try
{
using (var temporaryPath = new GraphicsPath(path.PathPoints, path.PathTypes))
{
context.Graphics.DrawPath(pen, temporaryPath);
}
}
}
Any help in here would be lovely! thanks in advance!
It's highly unlikely that this is the root cause of your problem considering that you are property disposing of the Pen and Path object.. That line may be throwing the exception, but the problem has already been brewing for some time and this is just the straw that broke the camel's back, tipped the iceberg... you get it. That said, it would be helpful to know how large your PathPoints
array is as Tigran mentioned in a comment.
Get yourself a good profiler (I use RedGate's ANTS Memory Profiler which has a free trial), put your app through it's paces, let the memory usage build up, and then use the profiler results to narrow down the actual culprit. Come back with some more info or your results and I will be happy to help further.
精彩评论