Zhenzhe He
Zhenzhe He

Reputation: 1

How to clear cache and buffer after QFile.write()

I am writing a download function in QT for a gigabyte level file.

In each readyRead of QNetworkreply, I connected to a custom function to do:

 m_file.write(data);
 m_file.flush();

m_file is a QFile.

I am assuming in this fashion cache should not be huge but it seems that cache was never cleared and keeps stacking up.

If I were to clear the cache after each file.write() and file.flush(), what should I do?

Upvotes: 0

Views: 86

Answers (1)

Stas Simonov
Stas Simonov

Reputation: 582

QFile::flush() ensures that the buffered data is written to disk by the means of operating system (OS). And the OS disk cache refers to the whole disk rather than to any file. So, the flushed buffer may not affect the cache size.

Upvotes: 0

Related Questions