Yes, it does create a byte array in RAM, copying the whole memory that is in your hard drive. So you will run into issues running QFile::readAll()
on huge files.
The documentation for QString QTextStream::readAll()
says:
Reads the entire content of the stream, and returns it as a QString. Avoid this function when working on large files, as it will consume a significant amount of memory.
It is not mentioned for QByteArray QIODevice::readAll()
(inherited by QFile
), but it will be the same, since there is no way the pointers in a QByteArray
can point somewhere in your hard disk (must be an address in the virtual memory allocated to the program by the OS, i.e. the stack or the heap).