Results 1 to 9 of 9

Thread: Signals / Slots increase the memory usage with Qt::QueuedConnection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    11
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Signals / Slots increase the memory usage with Qt::QueuedConnection

    Hello,
    first of all i want to say hello to this great forum

    Here my problem (I tried to find it on the internet, but I did not have luck):

    If i connect a simple slot (only writes a string on the console) to a signals and emit this signal a lot of times, the program's memory usage increases.
    But only, if i connect the signal to the slot with Qt::QueuedConnection. If it is direct connected, the memory sticks at the same size, as if i would never emit the signal.
    Why does this happens?
    Thank you and good night

    Here my code:

    main.cpp
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include "a.h"
    3.  
    4. int main(int argc, char *argv[]) {
    5. QCoreApplication app(argc, argv);
    6. A a;
    7. QObject::connect(&a, SIGNAL(testSig()), &a, SLOT(testSlot())/*, Qt::QueuedConnection*/);
    8. for (int i = 0; i < 50000; ++i) a.test();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    a.h
    Qt Code:
    1. #ifndef A_H
    2. #define A_H
    3.  
    4. #include <QObject>
    5.  
    6. class A : public QObject {
    7.  
    8. Q_OBJECT
    9.  
    10. public:
    11. A();
    12. void test();
    13.  
    14. public slots:
    15. void testSlot();
    16.  
    17. signals:
    18. void testSig();
    19. };
    20.  
    21. #endif // A_H
    To copy to clipboard, switch view to plain text mode 

    a.cpp
    Qt Code:
    1. #include "a.h"
    2.  
    3. A::A() {
    4. }
    5.  
    6. void A::testSlot() {
    7. qDebug("hi");
    8. }
    9.  
    10. void A::test() {
    11. emit testSig();
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by h0nki; 1st June 2009 at 01:05.

Similar Threads

  1. Bad memory usage on QWebView I think
    By jiturra in forum Qt Programming
    Replies: 15
    Last Post: 21st January 2014, 20:35
  2. Signals and Slots Problem
    By GenericProdigy in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2009, 09:06
  3. Signals and Slots
    By 83.manish in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 10:31
  4. Problem with SpinBox signals and slots
    By ramstormrage in forum Newbie
    Replies: 4
    Last Post: 2nd May 2008, 01:45
  5. Memory Problem with SIGNALS and SLOTS
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2007, 20:39

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
  •  
Qt is a trademark of The Qt Company.