Buffered http for large downloads?



  • Hi

    Referring to the code "here":http://qt-project.org/forums/viewthread/7228/

    Would this be performant in terms memory consumption etc with very large files? Would be grateful if someone could suggest if it's OK or not? Any suggestion on how the code could be modified?

    (Edit: the "http download example":http://qt-project.org/doc/qt-4.8/network-http-httpwindow-cpp.html in QtCreator works, but on my N8 Symbian device, i see memory full errors)

    thanks



  • on the HTTP example i see:

    @void HttpWindow::httpReadyRead()
    {
    // this slot gets called every time the QNetworkReply has new data.
    // We read all of its new data and write it into the file.
    // That way we use less RAM than when reading it at the finished()
    // signal of the QNetworkReply
    if (file)
    file->write(reply->readAll());
    }@

    But each time i run this on a physical device (N8 with 150 MB on C:) i see memory full messages on the N8 writing a 100MB file. Even though i was writing out the file to E:.

    Does the QT api somehow use the c:\ drive to temporarily hold the file until complete?

    thx



  • I have done some more experimentation and found that it's the WRITE causing the memory full. I even tried quick/dirty buffering and writing/flushing chunks:

    @ QByteArray b(reply->readAll());

    int t = b.size();
    qDebug() << "sz1: " << t;
    const int BUFFER_SIZE = 4096;
    int s = 0;
    int tw = 0;
    while (s < t) {
    int c = file->write(b.mid(s, BUFFER_SIZE)); // <---
    qDebug() << "written: " << c;
    tw += c;
    s += BUFFER_SIZE;
    }@

    Even this doesn't work. I mean that's like a 4K buffer right? Adding a flush() after each write (not a good idea anyway) makes the memory full error appear even faster. My N8 or E6 can't handle it. What's going on?


  • Moderators

    For symbian specific issues you might get better help over at developer.nokia.com. They might actually know the low level details of symbian.



  • In the end, painfully googling:

    I found i needed this in my .pro file

    @symbian: {
    TARGET.EPOCHEAPSIZE = 0x200000 0x2000000
    }@

    this sets the min and max heap size.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.