Hi, Can anyone help with my problem, please excuse my lack of programming expertise in advance

In my program I read in large files (sometimes a few hundred Mb) of comma separated values.

I read them in like so:

Qt Code:
  1. QFile file(inFile);
  2. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
  3. return;
  5. QTextStream in(&file);
  6. QString lineText;
  8. while (!in.atEnd())
  9. {
  10. lineText = in.readLine();
  11. }
To copy to clipboard, switch view to plain text mode 

Generally it reads files as expected apart from a few files where it crashes (error and stack frame below).
The strange thing is if I split the file in question into two halves then it works ok. I've checked There's nothing wrong with the files and It also works on much larger files without any problems.

I can see it's memory related and it's always happening at the same memory address.

Can anyone tell me whats going on?

Thanks in advance,


Qt Code:
  1. Unhandled exception at 0x1026edee (msvcr90d.dll) in test.exe:
  2. 0xC0000005: Access violation writing location 0x302d1000.
  4. msvcr90d.dll!memcpy(unsigned char * dst=0x302cc496, unsigned char * src=0x0249107a, unsigned long count=32768) Line 271
  5. QtCored4.dll!QString::append(const QString & str={...}) Line 1277 + 0x2d bytes
  6. QtCored4.dll!QString::operator+=(const QString & s={...}) Line 261 + 0x13 bytes
  7. QtCored4.dll!QTextStreamPrivate::fillReadBuffer(__int64 maxBytes=-1) Line 575 + 0x5b bytes
  8. QtCored4.dll!QTextStreamPrivate::scan(const QChar * * ptr=0x001275f4, int * length=0x001275fc, int maxlen=0, QTextStreamPrivate::TokenDelimiter delimiter=EndOfLine) Line 734 + 0x2a bytes
  9. QtCored4.dll!QTextStream::readLine(__int64 maxlen=0) Line 1583 + 0x16 bytes
  10. dev.exe!DTMfromXYZ::createDTM() Line 308 + 0x14 bytes
To copy to clipboard, switch view to plain text mode