Results 1 to 5 of 5

Thread: Long hang on application termination

  1. #1
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Long hang on application termination

    When i perform certain actions with my program, the program hangs for ~10-15 seconds on termination, at 100% cpu usage.

    The main thread is destrying a custom object (as it should), but appears to have some issues within the destructor of an
    Qt Code:
    1. typedef QMap<quint64, QSet< quint64> > trzf_cache;
    To copy to clipboard, switch view to plain text mode 

    object.

    So the hang happens within Qt-map code.

    Any ideas how any of my code could cause this?


    edit:
    completely rewrote posts with new details.
    Last edited by tuli; 19th April 2013 at 08:50.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Long hang on application termination

    When i perform certain actions with my program, the program hangs for ~10-15 seconds on termination, at 100% cpu usage.
    Describe "certain actions".

    So the hang happens within Qt-map code.
    How can you tell that the delay is in QMap code?

    Any ideas how any of my code could cause this?
    That will be a wild guess , unless we see code.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Long hang on application termination

    These "certain actions" is basically an entire sub-part of my program which makes extensive use of the datastruct defined above.
    I can tell because all stack traces i gather end up there.

    It appears that the data saved in the container(s) is about ~36 MB. An apparently it takes about 13 seconds to completely free it; and only then the program can be terminated.

    Thing is, i dont remember having this kind of overhead with past revisions...let me take a look at some commit logs here... :S

    There#s way too much code involved to show here - and i wouldnt even know what to show!
    It basically adds, reads, deletes, modifies data stored in the container. Mostly read access, once it's set up, though.


    Added after 1 35 minutes:


    Interesting obersvation:


    The data in trzf_cache is saved/loaded from/to disk using a QDataStream(). The filesize on disk vs. the memory consumption after loading it is 3x smaller, ie. 5MB on disk vs 15MB in memory.

    This is not the case when i generate the data at runtime (which takes 5 minutes). If i do, the memory consumption is only 2x the filesize on disk (possibly even less, as i suspect memory leaks in the data generation).

    And more importantly: with the data generated at runtime, there are no more delays when terminating the application!!


    I#d suspect a buggy QDataStream implementation, but usually it#s me who makes the mistakes, not the Qt Devs....
    I'll try to debug some more...but if anyone has an idea, kindly let me know.
    Last edited by tuli; 19th April 2013 at 15:42.

  4. #4
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Long hang on application termination

    Update:

    I refacrtored the code to use


    typedef QMap<quint64, QVector< quint64> > trzf_cache;
    instead of

    typedef QMap<quint64, QSet< quint64> > trzf_cache;

    and the problem appears to have gone.
    No idea what difference that makes as with QDataStream vs. runtime generation...

  5. #5
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Long hang on application termination

    No idea what difference that makes as with QDataStream vs. runtime generation...
    The difference: How would you describe a template providing Hash-Table based set with a template that provides dynamic array in terms of speed and efficiency ?

Similar Threads

  1. exporting QWS_KEYBOARD=LinuxInput:/dev/input/event0" hang application
    By binaural in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 12th September 2012, 07:03
  2. [Memory managament] long liveliness of application
    By Blood9999 in forum Qt Programming
    Replies: 22
    Last Post: 17th August 2012, 23:22
  3. QSqlDatabase best practices with long-running application
    By redBeard in forum Qt Programming
    Replies: 6
    Last Post: 17th October 2011, 19:32
  4. Wait for socket to connect without application hang?
    By hakermania in forum Qt Programming
    Replies: 5
    Last Post: 9th October 2011, 11:03
  5. Replies: 3
    Last Post: 19th March 2011, 05:02

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.