c# Chart out of memory exception

1

C# Chart OutOfMemory Exception in System.Drawing.DLL happens on HitTest call in MouseMove:

private void chart1_MouseMove(object sender, MouseEventArgs e)
{
    if (chart1.Series[0].Points.Count > 0)
    {
        HitTestResult[] results = chart1.HitTest(e.X, e.Y, true, ChartElementType.PlottingArea);
                
        foreach (HitTestResult result in results)
        {
            if (result.ChartElementType == ChartElementType.PlottingArea)
            {
                // e.g. display co-ords of where we're hovering
            }
        }
    }
}

The debugger shows:

System.OutOfMemoryException
  HResult=0x8007000E
  Message=Out of memory.
  Source=System.Drawing
  StackTrace:
   at System.Drawing.Drawing2D.GraphicsPath.Widen(Pen pen, Matrix matrix, Single flatness)

  This exception was originally thrown at this call stack:
    System.Drawing.Drawing2D.GraphicsPath.Widen(System.Drawing.Pen, System.Drawing.Drawing2D.Matrix, float)

Any ideas as I'm baffled?

c#
winforms
exception
charts
mousemove
asked on Stack Overflow Feb 2, 2021 by DaveR • edited Feb 2, 2021 by Peter B

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0