Download with QNetworkAccessManager / QNetworkReply using readyRead() eats my RAM

914 Views Asked by At

I'm having the following setup and scenario:

  • QT/QML-application running, which can be triggered to download a 20MB file to /tmp/IMAGE (using QNetworkManager(), QNetworkReply(), readyRead())
  • /tmp is a ramdisk - having 40+MB of available space (while the QT/QML-application is running)
  • I can easily wget the 20MB file to /tmp/IMAGE while the QT/QML-application is running

however when trying to download the file via the QT/QML-application (using QNetworkManager(), QNetworkReply() and the readyRead()-signal, the qt/qml-application gets killed by the out-of-memory killer even before half the file is actually downloaded (according to downloadProgress() and size of /tmp/IMAGE).

As far as I understood, readyRead() is especially designed for partially downloading chunks, writing it to disk, clearing its used RAM and downloading and writing the next chunk.

However that method seems to massively consume more RAM, than e.g. using wget - after having 10MB of the file downloaded, the Qt/QML-application has a huge memory footprint which I can't explain.

What I'm basically doing, it connecting the readyRead() with my slot named partialDownloadFinished() which only does: file->write(reply->readAll());

I also checked whether the chunk size might be or might get to large via bytesAvailable(), however that also doen't seem to be the case.

My next guess was that data is downloaded faster than being written to (ram)disk, however that also doesn't seem to be the case.

So I'm stuck. Anybody having any clue or hint on this?

Thanks a lot!

0

There are 0 best solutions below