Results 1 to 6 of 6

Thread: Problem with releasing class resources while finishing application

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Problem with releasing class resources while finishing application

    Hello!

    Some time ago my application used to store quite a bunch of data into a QVector of structs (something like 450 Mb). When the app was finished while having the data stored it, it would happen quickly. But some time ago I changed the struct-based containing and create a similar class so I could have a better programming. Now I work with a QVector of objects from a given class. Unfortunately, since I did this change the app now takes quite a time to be actually finished after I click the MainWindow's close button - the window itself is closed, but when I go to the task manager I can see the .exe in the executable list for more two to five seconds, and this running in release mode.

    I would like to know more about this situation: is it normal for this to happen? Shouldn't the change makes no effect at all? Does this means as well that my app will possibly be slower while dealing with my data, specially when I had to erase part of it while working with the app opened? Is there a way Qt provides for quick data erasing?

    Thanks,

    Momergil

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Problem with releasing class resources while finishing application

    Hi,

    have you only substitute "struct" through "class"? No other change at all? How does the structure of the new class look like?

    best

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Problem with releasing class resources while finishing application

    I am not sure how much we can tell you about what your program is doing between when the last window closes and exit. Deleting a serious number of heap allocated objects might take some time especially if their destructor does something significant... but only you know what your program has to do, and it may not be this. It might be the orderly teardown of network or database connections.

  4. #4
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with releasing class resources while finishing application

    Quote Originally Posted by Lykurg View Post
    Hi,

    have you only substitute "struct" through "class"? No other change at all? How does the structure of the new class look like?

    best
    You may see by yourself (only relevant data displayed):

    Qt Code:
    1. //Old struct-based:
    2.  
    3. struct periodical_data
    4. {
    5. QList<time_frame> baseData;
    6. QList<figure_congestion_rectangular> rectangles;
    7. QList<figure_congestion_triangles> triangles;
    8. QList<figure_channels> channels;
    9. QList<basic_price_value> zig_zag_sequence;
    10. QList<pivot> pivots;
    11. };
    12.  
    13. struct share //Structure that contains all data about a share
    14. {
    15. periodical_data periodicity[PERIOD_MAX];
    16. };
    To copy to clipboard, switch view to plain text mode 

    vs.

    Qt Code:
    1. //New class-based:
    2.  
    3. struct periodical_data
    4. {
    5. QList<time_frame> baseData;
    6. QList<figure_congestion_rectangular> rectangles;
    7. QList<figure_congestion_triangles> triangles;
    8. QList<figure_channels> channels;
    9. QList<basic_price_value> zig_zag_sequence;
    10. QList<pivot> pivots;
    11. };
    12.  
    13. class share //Class that contains all data about a share
    14. {
    15. public:
    16. explicit share() { /*does nothing*/ }
    17. ~share(); //does nothing
    18.  
    19. private:
    20. periodical_data periodicity[PERIOD_MAX];
    21. };
    To copy to clipboard, switch view to plain text mode 


    Added after 8 minutes:


    Quote Originally Posted by ChrisW67 View Post
    Deleting a serious number of heap allocated objects might take some time especially if their destructor does something significant...
    ...

    It might be the orderly teardown of network or database connections.
    Well Chris, I wouln't be surprised if my software took some time to exit given the amount of data I load. The strange thing is that this problem didn't exist when I used structs, but it appeared when I changed it to classes. But nope, my destructor actually don't do anything. No database connections either or network issues; the only thing is the data I load from .csv files into my objects. When this is not performed, the app closes in normal speed, so to speak.
    Last edited by Momergil; 12th May 2013 at 20:03.

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

    Default Re: Problem with releasing class resources while finishing application

    I have the same problem, and my destructors dont do anything special (in fact, there is no custom destructor).
    Switched the container from QList to QVector, no change.
    WHen i use std:: equivalents, i do not have this problem...

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Problem with releasing class resources while finishing application

    What happens if you remove the do-nothing destructor? Essentially the only difference here is the presence of the destructor in the class vs struct and the corresponding call during destruction.

Similar Threads

  1. Qprocess and mpi not finishing
    By Spifffers in forum Qt Programming
    Replies: 10
    Last Post: 2nd April 2016, 18:40
  2. Replies: 8
    Last Post: 5th November 2012, 08:43
  3. Releasing application is not retard-proof.
    By Pascal666 in forum Installation and Deployment
    Replies: 1
    Last Post: 11th December 2010, 12:03
  4. Replies: 0
    Last Post: 4th March 2009, 19:27
  5. Distributing an application with resources
    By ntp in forum Qt Programming
    Replies: 3
    Last Post: 6th October 2007, 01:46

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.