Results 1 to 4 of 4

Thread: Craching in QQueue

  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Craching in QQueue

    Hi all,
    I am working with a real time application where in i need to handle the data coming from socket at a speed of 2MBps.
    i am using QQueue<QByteArray> where in i am reading 22 Bytes and storing it as QByteArray in QQueue after storing this data i will process it by taking 22Bytes at a time and updating it to a Qtreeview using QStandardItemModel.
    my problem is i am not able to update the model at the rate at which the data is coming from socket resulting the QQueue is overloaded with huge data at after some time it is getting crashed.

    Requesting help for the same.

    Thanks in Advance.
    Kiran Pechetti

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Craching in QQueue

    You do not provide enough information, and no code, so there is not much we can do to help you.

    What does your program do exactly? I will take a few shots in the dark here. You seem to have a producer that reads data in blocks of 22 bytes from a socket and enqueues them as QByteArrays in the QQueue, and a consumer that dequeues and processes them. The producer and consumer run in parallel (in distinct threads?) and the consumer is not as fast as the producer, causing the queue to grow until the process goes out of memory.

    Is that correct? Until you provide details and code I am afraid all you can get are generic (a.k.a. useless) answers.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Craching in QQueue

    Thanks for your response.
    Your assumption is right only thing differs is the producer and consumer runs in the same thread in my application.

    Kindly revert for further clarification.
    Kiran Pechetti

  4. #4
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Craching in QQueue

    Then if the producer and consumer run in the same thread how do you schedule them? I suppose that you enqueue a QByteArray as soon as you receive 22 bytes in reaction to the socket's readyRead() signal. But how do you decide that it is time to dequeue a QByteArray to process it?

    You need a smart strategy for deciding when to process a bunch of QByteArrays, because the application will not be reading from the socket in that time frame. Or maybe a simpler design works, in which you just process every QByteArray as soon as you receive it, not bothering to go through a queue.

    In any case, you can only hope to meet the real time requirements of your application if, on average, processing a QByteArray is faster than receiving it.

Similar Threads

  1. QQueue vs STL queue
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 8th November 2007, 18:35
  2. QQueue:QList::QStack:QVector?
    By jamadagni in forum Qt Programming
    Replies: 2
    Last Post: 20th August 2007, 13:29
  3. QThread and QQueue
    By qball2k5 in forum Qt Programming
    Replies: 19
    Last Post: 15th August 2006, 17:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.