문제

I want to ask that if the QFile().readAll () , returns a QByte Array then does it create a byte array on Physical memory or just provides a linked list address containing the positions of Bytes?.

can it create problem in the case of large files which are in GBs.

도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top