I've written some data into a file the following way:
result = new QHash<QPair<int, int>, QVector<double> >;
QFile resfile("result.txt");
resfile.open(QIODevice::WriteOnly | QIODevice::Append);
QDataStream out(&resfile);
while(condition)
{
QString s=" something";
out<<s;
res->insert(QPair<int, int>(arange,trange),coeffs);
out<<res;
}
The file ended up with the equal to 484MB. After that i read it in a loop:
QString s;
QVector<QHash<QPair<int, int>, QVector <double> > > thickeness_result;
QFile resfile("result.txt");
resfile.open(QIODevice::ReadOnly);
QDataStream out(&resfile);
while (!out.atEnd())
{
thickeness_result.resize(thickeness_result.size()+1);
out>>s>>thickness_result.last();
}
While this read loop is running i see that in the task manager my program starts taking about 1300MB of memory and after that i receive an "In file text\qharfbuzzng.cpp, line 626: Out of memory" error. My question is: Is it normal that program starts taking more that 2x size of file memory and i should read it in chunks or am i doing something wrong?