title: WPF out of memory error when loading large amount of data
body: <p>I need to process large amount of data into a single <code>List&lt;ChartData&gt;</code> for my custom control.
  About 3 Million points it works fine after reaching the List Count 80,00,000 It throws the Out of memory error. Is there any count limit for List? Yes means shall I use any other Collection rather then the List.</p>
  
  <p>Is there a better technique to load large amounts of data into memory?
  The proplem is in the following function.If ChartIndexedDataPoint.Count is goes to above 30,00,000</p>
  
  <pre><code> protected override void CalculateSegments(ChartSeries series, ChartIndexedDataPoint[] points)
      {
          double[] yCoef={0};
          IChartDataPoint startPoint = null;
          IChartDataPoint endPoint = null;
          ChartPoint startControlPoint = null;
          ChartPoint endControlPoint = null;
          if (points.Length &gt;= 2)
          {
              NaturalSpline(points, out yCoef);
              if (series.ShowEmptyPoints == false &amp;&amp; series.Area.EnableLazyLoading == true)
              {
                  allpoints = new List&lt;IChartDataPoint&gt;();
                  if (series.ActualYAxis.IsAutoSetRange == true || series.ActualXAxis.IsAutoSetRange == true)
                  {
                      series.Segments.Clear();
                      series.Adornments.Clear();
  
                      for (int i = 0, count = points.Length; i &lt; count - 1; i++)
                      {
                          startPoint = points[i].DataPoint;
                          endPoint = points[i + 1].DataPoint;
                          GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                          allpoints.Add(startPoint);
                          allpoints.Add(startControlPoint);
                          allpoints.Add(endControlPoint);
                          allpoints.Add(endPoint);
                      }
                      series.Segments.Add(new ChartFastSplineSegment(allpoints, points, series)); 
                      return;
                  }
                  if (series.Segments.Count != 0)
                  {
                      ChartFastSplineSegment segment = ((ChartFastSplineSegment)series.Segments[0]);
  
                      if (segment.Points != null &amp;&amp; segment.Points.Count &lt; points.Length)
                      {
                          segment.GetSegmet(points[points.Length - 1].DataPoint, series);
                      }
                      else if (segment.Points == null || segment.Points.Count &gt; points.Length)
                      {                           
                          for (int i = 0, count = points.Length; i &lt; count - 1; i++)
                          {
                              startPoint = points[i].DataPoint;
                              endPoint = points[i + 1].DataPoint;
                              GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                              allpoints.Add(startPoint);
                              allpoints.Add(startControlPoint);
                              allpoints.Add(endControlPoint);
                              allpoints.Add(endPoint);
                          }
                          segment.UpdateSegment(allpoints, series);
                          segment.refresh = true;
                      }
                  }
                  else
                  {                        
                      for (int i = 0, count = points.Length; i &lt; count - 1; i++)
                      {
                          startPoint = points[i].DataPoint;
                          endPoint = points[i + 1].DataPoint;
                          GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                          allpoints.Add(startPoint);
                          allpoints.Add(startControlPoint);
                          allpoints.Add(endControlPoint);
                          allpoints.Add(endPoint);
                      }
                      series.Segments.Add(new ChartFastSplineSegment(allpoints, points, series)); 
                  }
              }
              else if (series.Segments.Count == 0 || series.internaldata_modified || allpoints.Count &gt; points.Length)
              {
                  allpoints = new List&lt;IChartDataPoint&gt;();
                  series.Segments.Clear();
                  series.Adornments.Clear();
                  ChartIndexedDataPoint[] pts = points;
                  List&lt;ChartIndexedDataPoint&gt; tempPointArray = new List&lt;ChartIndexedDataPoint&gt;();                    
                  for (int i = 0; i &lt; pts.Length-1; i++)
                  {
                      switch (pts[i].DataPoint.EmptyPoint)
                      {
                          case false:
                              {
                                  startPoint = points[i].DataPoint;
                                  endPoint = points[i + 1].DataPoint;
                                  GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                                  allpoints.Add(startPoint);
                                  allpoints.Add(startControlPoint);
                                  allpoints.Add(endControlPoint);
                                  allpoints.Add(endPoint);
                                  tempPointArray.Add(pts[i]);
                                  break;
                              }
                          case true:
                              {
                                  if (allpoints.Count &gt; 0)
                                  {
                                      if (i &lt; points.Length)
                                      {
                                          startPoint = points[i].DataPoint;
                                          endPoint = points[i + 1].DataPoint;
                                          GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[i + 1], out startControlPoint, out endControlPoint);
                                          allpoints.Add(startPoint);
                                          allpoints.Add(startControlPoint);
                                          allpoints.Add(endControlPoint);
                                          allpoints.Add(endPoint);
                                      }
                                      tempPointArray.Add(points[i]);
  
                                  }
                                  break;
                              }
                      }
                  }
                  if (tempPointArray.Count != 0 &amp;&amp; allpoints.Count != 0)
                  {
                      series.Segments.Add(new ChartFastSplineSegment(allpoints, tempPointArray.ToArray(), series));
                  }
              }
              if (series.Segments.Count &gt; 0)
              {
                  List&lt;ChartIndexedDataPoint&gt; tempPointArray = new List&lt;ChartIndexedDataPoint&gt;();
                  List&lt;ChartIndexedDataPoint&gt; pts = points.ToList();
  
                  if (!series.Contains_emptypt)
                  {
                      int cnt = (allpoints.Count+4)/4;
                      while ((allpoints.Count + 4) / 4 != points.Length &amp;&amp; (allpoints.Count + 4) / 4 &lt; points.Length)
                      {
                          startPoint = points[cnt-1].DataPoint;
                          endPoint = points[cnt].DataPoint;
                          GetBezierControlPoints(startPoint, endPoint, yCoef[cnt-1], yCoef[cnt], out startControlPoint, out endControlPoint);
                          allpoints.Add(startPoint);
                          allpoints.Add(startControlPoint);
                          allpoints.Add(endControlPoint);
                          allpoints.Add(endPoint);
                          cnt++;
                      }
                  }
                  (series.Segments[0] as ChartFastSplineSegment).m_points = allpoints;
                  if (series.ActualXAxis.IsAutoSetRange || series.Zoomactionenabled)
                  {                        
                      double X_MAX = allpoints.Max(x =&gt; x.X);
                      double X_MIN = allpoints.Min(x =&gt; x.X);
                      (series.Segments[0] as ChartFastSplineSegment).xRange = new DoubleRange(X_MIN, X_MAX);//xRange + cdpt.X;
                      if (series.ActualXAxis.RangeCalculationMode == RangeCalculationMode.AdjustAcrossChartTypes)
                      {
                          (series.Segments[0] as ChartFastSplineSegment).xRange += (series.Segments[0] as ChartFastSplineSegment).xRange.Start - 0.5;
                          (series.Segments[0] as ChartFastSplineSegment).xRange += (series.Segments[0] as ChartFastSplineSegment).xRange.End + 0.5;
                      }
                      (series.Segments[0] as ChartFastSplineSegment).SetRange(series);
  
                  }
                  if (series.ActualYAxis.IsAutoSetRange || series.Zoomactionenabled)
                  {                        
                      double Y_MAX = allpoints.Max(y =&gt; y.Y);
                      double Y_MIN = allpoints.Min(y =&gt; y.Y);
  
                      (series.Segments[0] as ChartFastSplineSegment).yRange = new DoubleRange(Y_MIN, Y_MAX);//yRange + cdpt.Y;
  
                      if (series.ActualXAxis.RangeCalculationMode == RangeCalculationMode.AdjustAcrossChartTypes)
                      {
                          (series.Segments[0] as ChartFastSplineSegment).xRange += (series.Segments[0] as ChartFastSplineSegment).xRange.Start - 0.5;
                          (series.Segments[0] as ChartFastSplineSegment).xRange += (series.Segments[0] as ChartFastSplineSegment).xRange.End + 0.5;
                      }
  
                      (series.Segments[0] as ChartFastSplineSegment).SetRange(series);
                      if (series.Zoomactionenabled)
                      {
                          series.Zoomactionenabled = false;
                      }
                  }
              }
          }     
      }
  </code></pre>