PDA

View Full Version : QFile::read failing on XP SP3



drescherjm
7th April 2009, 22:52
I am trying to read a 131MB file on windows XP into a buffer I allocated and I am getting the following error.

"Insufficient system resources exist to complete the requested service."

I see in the Qt4.4 source code that the reads are limited to 32MB to try to avoid this problem however I am still hitting it when the source is a network drive. I guess I could ask for even smaller chunks but I need the read to be reliable.

Ideas? Solutions / workarounds?

drescherjm
7th April 2009, 23:27
I made my max read size at 1 MB but this makes me nervous.

marcel
7th April 2009, 23:37
That's a Windows error, not a Qt one (QFile::read just uses winapi).
http://support.microsoft.com/kb/913872

drescherjm
7th April 2009, 23:47
I expected as much. Especially that it was not fixed in 3 years!

Looks like I will be extending the QFile class to deal with this..

Specifically I will override

QIODevice::readData

with my own function to workaround the windows bug..

BTW, this does not seem to happen on writes since Qt happily created the 131MB file in one call to QIODevice::write(buff,size);

marcel
7th April 2009, 23:52
That's not gonna do it. The workaround suggested you use FILE_FLAG_NO_BUFFERING when you open the file (with CreateFile (http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx)).
You can then use ReadFile (http://msdn.microsoft.com/en-us/library/aa365467%28VS.85%29.aspx)to read data.

Not really necessary to subclass QIODevice, unless you're building the app for other platforms than win.

drescherjm
8th April 2009, 01:20
Not really necessary to subclass QIODevice, unless you're building the app for other platforms than win.

I am building the application for linux and windows and in the future Macintosh. With my build system I can easily have any kludges compiled in or out depending on the system.

drescherjm
8th April 2009, 01:24
That's not gonna do it. The workaround suggested you use FILE_FLAG_NO_BUFFERING when you open the file (with CreateFile (http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx)).
You can then use ReadFile (http://msdn.microsoft.com/en-us/library/aa365467%28VS.85%29.aspx)to read data.

I know. I am going to look into the ramifications of doing that before I make it permanent.

drescherjm
15th April 2009, 22:59
BTW,

The windows version of the same code is failing in the _read() in the same way on the same input file as expected..