Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Buffered http for large downloads?
Forum Updated to NodeBB v4.3 + New Features

Buffered http for large downloads?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gurpal2000
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gurpal2000
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gurpal2000
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gurpal2000
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved