My program loops through an array of null elements, assigning each element to a new object (an instance of a class I made). The array gets quite large - about 60,000 elements in size. On occasion, this loop will work, but generally the program will crash, giving a generic microsoft error "x.exe has encountered a problem and needs to close...". I have concluded that this is not a memory <i>size</i>issue, but could be a memory management issue of some sort...

Here is the Point class:

Code:
public partial class Point
    {
        private string m_ID; // Theoretically to be used only for the transmitter point locations... Could be used for other points too depending on application...
        public double x, y, power;
        public string m_time;

        public Point()
        {
            power = 0;
        }

        public Point(double x, double y)
        {
            this.x = x; this.y = y; power = 0;
        }

        public Point(double x, double y, int column)
        {
            this.x = x; this.y = y; power = 0;
        }

        public Point(double x, double y, int column, string time)
        {
            m_time = time; this.x = x; this.y = y; power = 0;
        }

        public Point(double x, double y, int column, string time, double power)
        {
            m_time = time; this.x = x; this.y = y; this.power = power;
        }

        /// <summary>
        /// THE LABEL OR NAME OF THE GIVEN POINT.
        /// </summary>
        public string ID
        {
            get
            {
                return m_ID;
            }
            set
            {
                m_ID = value;
            }
        }

        public string time
        {
            get
            {
                return m_time;
            }
            set
            {
                m_time = value;
            }
        }
    }
And here is the function which builds the array of Point's:

Code:
public Point[] getPoints(ExcelInterface excelData)
        {
            int longColumn = excelData.FindColumnNumber("Longitude");
            int latColumn = excelData.FindColumnNumber("Latitude");
            int timeColumn = excelData.FindColumnNumber("Time");
            int powerColumn = excelData.FindColumnNumber("Power_dBm");

            Point[] dataPoints = new Point[excelData.rows];

            string hh, mm, ss, MM, dd;
            hh = string.Empty; mm = string.Empty; ss = string.Empty; MM = string.Empty; dd = string.Empty;
            int hour, minute, second;
            double power;
            DateTime time;
            double[] thresholds = getPowerThresholds(numThresholds, excelData);
            string dateTime, timeString;

            if (System.DateTime.Now.Month < 10)
                MM = "0" + System.DateTime.Now.Month.ToString();
            else MM = System.DateTime.Now.Month.ToString();

            if (System.DateTime.Now.Day < 10)
                dd = "0" + System.DateTime.Now.Day.ToString ();
            else dd = System.DateTime.Now.Day.ToString();

            string date = System.DateTime.Now.Year + "-" + MM + "-" + dd;
            double lat, lon;

            // array stop between 1900 and 2000 in size...
            for (int i = 2; i < excelData.rows; i++)
            {
                if (i % 400 == 0)
                {
                }

                time = new DateTime(); // DEBUG
                lat = (double)excelData.GetCellValue(i, latColumn, 1);
                lon = (double)excelData.GetCellValue(i, longColumn, 1);
                time = (DateTime)excelData.GetCellValue(i, timeColumn, 1);
                power = (double)excelData.GetCellValue(i, powerColumn, 1);

                hour = time.Hour;
                if (hour < 10)
                    hh = "0" + hour.ToString();
                else hh = hour.ToString();

                minute = time.Minute;
                if (minute < 10)
                    mm = "0" + minute.ToString();
                else mm = minute.ToString();

                second = time.Second;
                if (second < 10)
                    ss = "0" + second.ToString();
                else ss = second.ToString();

                timeString = "T" + hh + ":" + mm + ":" + ss + "Z";
                dateTime = date + timeString;

                try
                {
                    dataPoints[i - 2] = new Point(lon, lat, i, dateTime);  // dataPoints[i - 2] = new Point(lon, lat, i, dateTime);
                }
                catch (Exception ex)
                {

                }
            }
I have also tested this by simplifying the loop where the error occurrs, by using only the constructor:

Code:
   for (int i = 2; i < excelData.rows; i++)
            {
                try
                {
                    dataPoints[i - 2] = new Point(0, 0, 0, "");  
                }
                catch (Exception ex)
                {
                }
}
The program still crashed with this test scenario. I have also built a simple test program which solely creates a point array and assigns each array element to a new Point. That program worked just fine with over 1million elements...

I would really appreciate any help - Ive been wrestling with this for days!

Rich