Click here to Skip to main content
15,744,010 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am working on the following code to filter the data from log file which is having very huge data


C#
for (int m = 0; m < CANMsgIdList.Count; m++)
            {


                if (CANMsgIdList[m].Bus == ConsoleApplication13.Buses.CANBusRed)
                {
                    reds.Add(index);
                    
                }
                index++;

            }

            List<double> times = new List<double>();
           
            foreach (var i in reds)
            {

                for (int j = 1; j<index; j++)
               // for (int j = 1; (!(CANMsgIdList[i].MsgId == CANMsgIdList[j].MsgId)) && (j < i); j++)
                {

                    if ((CANMsgIdList[j].Bus).Equals(ConsoleApplication13.Buses.CANBusYellow) &&(CANMsgIdList[j].TimeStamp > CANMsgIdList[i].TimeStamp) )
                    
                    {
                        times.Add(CANMsgIdList[j].TimeStamp- CANMsgIdList[i].TimeStamp);
                        
                    }
                }
            }
            double av = times.Sum() / times.Count;
            //double av = times.Count;
            Console.WriteLine(av);


But I am getting the following error at the line
C#
times.Add(CANMsgIdList[j].TimeStamp- CANMsgIdList[i].TimeStamp);


Error
C#
An unhandled exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll


Can anyone help me in solving this???

Thanks
John
Posted
Comments
[no name] 30-Dec-13 4:07am    
The List<double> times that yo use,have a limit size when it pass the limit it throw this exception. try to create 2 double one for sum and the second for count:
double count_=0,sum_=0;
foreach (var i in reds)
{

for (int j = 1; j<index; j++)
="" for="" (int="" j="1;" (!(canmsgidlist[i].msgid="=" canmsgidlist[j].msgid))="" &&="" (j="" <="" i);="" {
=""
="" if="" ((canmsgidlist[j].bus).equals(consoleapplication13.buses.canbusyellow)="" &&(canmsgidlist[j].timestamp=""> CANMsgIdList[i].TimeStamp) )

{
count_++;
sum_=sum_+(CANMsgIdList[j].TimeStamp- CANMsgIdList[i].TimeStamp);

}
}
}
ZurdoDev 2-Jan-14 16:04pm    
What's the value of times.Count when this happens?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900