Results 1 to 4 of 4

Thread: how can release the memory after closing tab widget?

  1. #1
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default how can release the memory after closing tab widget?

    I am using a tabwidget and adding tabs dynamically in runtime...
    Each tab contains many widgets....
    But if i close a tab, its memory is not releasing....how can i handle it?


    code in adding tab
    Qt Code:
    1. ui->tabWidget_unfiltered->addTab(filesTable,FileName);
    To copy to clipboard, switch view to plain text mode 

    aftr closing tab
    Qt Code:
    1. ui->tabWidget_unfiltered->removeTab(index);
    To copy to clipboard, switch view to plain text mode 


    Here each tab contains a table widget....
    And storing each those table in a hash table as
    QHash<QString,QTableWidget*> StoredTables;

    Hence when i delete that tab, i'm just removing this hash entry as..
    Qt Code:
    1. StoredTables.remove(RmovedFilename);
    To copy to clipboard, switch view to plain text mode 
    but when i check in Task bar->memory(private eorking set) , the memory is not deallocating after closing the tab....
    What should i do?
    Last edited by aurora; 14th February 2012 at 06:23.

  2. #2
    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: how can release the memory after closing tab widget?

    Ummm, you delete it.
    Qt Code:
    1. QWidget *tab = ui->tabWidget_unfiltered->widget(index);
    2. ui->tabWidget_unfiltered->removeTab(index);
    3. delete tab;
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to ChrisW67 for this useful post:

    Alir3z4 (14th February 2012)

  4. #3
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how can release the memory after closing tab widget?

    Ok thank u...how can i release the memory in hash table....?

  5. #4
    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: how can release the memory after closing tab widget?

    Empty the hash table (QHash::clear()), delete the hash table.... really depends on what you mean.

Similar Threads

  1. Memory returned for child widgets after closing
    By koan in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2011, 15:36
  2. Memory Release
    By mukunda in forum Qt Programming
    Replies: 3
    Last Post: 12th February 2011, 18:27
  3. Dynamic memory release
    By linuxdev in forum Qt Programming
    Replies: 5
    Last Post: 11th December 2008, 06:22
  4. It seems that Qt does not release unused memory
    By iw2nhl in forum Qt Programming
    Replies: 31
    Last Post: 25th November 2007, 20:02
  5. Replies: 3
    Last Post: 17th October 2007, 12:52

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.