Results 1 to 5 of 5

Thread: How to release memory before Qt's Program finished ?

  1. #1
    Join Date
    Mar 2011
    Posts
    20
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to release memory before Qt's Program finished ?

    Hi all ,

    i'm writing a really big(fat?) program ,
    there's lots of function on this program ,
    and i use a lot of widget / dialog box ...something like that ,
    and i also add Qt::WA_DeleteOnClose ,
    but seems like Qt will not release ram space back to system?

    i've test to open all my function and close ,
    at first my program run , it only take 1.7% of memory
    after all the function open once , it take 2.2% ~ 2.3% of memory
    and it keep in 2.2%~2.3% of memory usage , no matter the function opend twice or more times


    Is there anyway to release Qt's memory back to system ?

    thanks for any reply~

  2. #2
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to release memory before Qt's Program finished ?

    Actually memory released on program exit by OS itself. But if you worry about memory usage during program work, then it seems you have memory leaks inside your code.
    Last edited by Oleg; 2nd December 2011 at 13:08. Reason: reread question
    Oleg Shparber

  3. #3
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to release memory before Qt's Program finished ?

    don't worry. Just because you "delete" an object doens't mean the memory gets back to the operating system. your programm might keep this part reserved for future allocations.

  4. #4
    Join Date
    Jul 2011
    Location
    Brasil
    Posts
    39
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to release memory before Qt's Program finished ?

    Hi,

    That is, the OS keep some memory for reallocations, it is for "increase" agility when doing that...
    On Windows-based environment you can use the SetProcessWorkingSetSize, from Windows API... Sending the last two parameters a -1.
    It will "removes as many pages as possible from the working set of the specified process." - http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx.
    This will not release any memory allocated by the program itself, just what OS think will be allocated again...

    I don't know if there is a POSIX equivalent...


    Hth.

  5. #5
    Join Date
    Mar 2011
    Posts
    20
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to release memory before Qt's Program finished ?

    Thanks for all your reply ,
    i will try to find if there is any command like "SetProcessWorkingSetSize" under linux ,
    and check my program if there is any memory leaks .

Similar Threads

  1. Replies: 2
    Last Post: 10th November 2011, 07:58
  2. Memory Release
    By mukunda in forum Qt Programming
    Replies: 3
    Last Post: 12th February 2011, 18:27
  3. Program has unexpectedly finished
    By Maluko_Da_Tola in forum Newbie
    Replies: 5
    Last Post: 1st December 2010, 09:54
  4. Dynamic memory release
    By linuxdev in forum Qt Programming
    Replies: 5
    Last Post: 11th December 2008, 06:22
  5. It seems that Qt does not release unused memory
    By iw2nhl in forum Qt Programming
    Replies: 31
    Last Post: 25th November 2007, 20: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.