with my application in Qt I'm currently trying to read a really big formatted text file (20.000.000 of lines) and collecting data in some QStringLists (plural).
Each lines generates 4 QStringList components of 10 characters each.
Always at the same point the application crashes with the "Runtume Error!".
I'm saying the same point because if I try to remove the last line read, I got the error at the next one. (I'm talking about crashing at the 16.000.000th line )
I'm not sure (nor so skilled...), but I think I sort of reached the memory capability, could it be the case? is there some work-around or some better way in doing that?
here is part of the code where I collect the data from the text file:
int lcCount=0;
QStringList loadcase, elid, plyid, eltyp, sigmax, sigmay, sigmaz, sigmaxy, sigmaxz, sigmayz;
QString currentLC, currentELtyp;
QStringList status; status<<"LCoff"<<"ELoff"<<"PLYoff";
QStringList lineList;
while(!in.atEnd())
{
//PROGRESS BAR
int pBarValue = countRow*100/countTotRow;
//qDebug()<<countRow<<" - " << countTotRow;
m_pBar->avanzamentoPCH(pBarValue);
qApp->processEvents();
QString line = in.readLine(); countRow++;
if(line.contains("$TITLE")){status.replace(0,"LCoff");status.replace(1,"ELoff");}
if (line.contains("$SUBCASE ID ="))
{
status.replace(0,"LCon");
line.chop(30);
line.remove(" ");
line.remove("$SUBCASEID=");
currentLC = line;
lcCount++;
} else if (line.contains("$ELEMENT TYPE =") && status.at(0)=="LCon")
{
line.chop(30);
line.remove("$ELEMENT TYPE =");
lineList = line.split(" ",QString::SkipEmptyParts);
// creazione stringa del tipo di elemento
currentELtyp = lineList.at(1);
currentELtyp.chop(2);
currentELtyp.prepend("C");
if((lineList.at(1).contains("QUAD4LC")) || (lineList.at(1).contains("TRIA3LC")))
{
status.replace(1,"ELon");
}
lineList.clear();
} else if(status.at(0)=="LCon" && status.at(1)=="ELon")
{
line.chop(8); // elimina gli ultimi 8 caratteri evitando possibili errori quando il numero delle righe del pch si attacca all'ultimo valore
loadcase << currentLC;
eltyp<<currentELtyp;
lineList = line.split(" ",QString::SkipEmptyParts); //,QString::SkipEmptyParts
elid << lineList.at(0);
plyid << lineList.at(1);
sigmax << lineList.at(2);
sigmay << lineList.at(3);
lineList.clear();
line = in.readLine();countRow++;
line.chop(8); // elimina gli ultimi 8 caratteri evitando possibili errori quando il numero delle righe del pch si attacca all'ultimo valore
lineList = line.split(" ",QString::SkipEmptyParts);
sigmaxy << lineList.at(1);
sigmaxz << lineList.at(2);
sigmayz << lineList.at(3);
lineList.clear();
//
line = in.readLine();countRow++;
line = in.readLine();countRow++;
// solo per laminati!!
sigmaz << "0.0";
}
}
and here is an example of the text file: a part like this format goes on and on
650001 1 -1.919393E+05 5.581818E+05 8
-CONT- -1.747859E+03 -8.388188E+01 -4.930236E+01 9
-CONT- -8.986650E+01 5.581859E+05 -1.919434E+05 10
-CONT- 3.750646E+05 11