Results 1 to 3 of 3

Thread: Memory issue when close QMdiSubWindow

  1. #1
    Join Date
    Aug 2013
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Question Memory issue when close QMdiSubWindow

    Hi all,

    We have a MDI application, using QMdiSubWindow as tabbed windows. As shown in htop, each QMdiSubWindow (and its internal widget with data) will consume 8M memory.
    So, when I create more and more QMdiSubWindow, say 10, the total memory consumed by the application will gradually increase.
    That's OK. The problem is when I close the existing QMdiSubWindow, the memory won't decrease.

    We have set WA_DeleteOnClose attribute to delete QMdiSubWindow when closing.
    setAttribute(Qt::WA_DeleteOnClose);

    I know memory allocated to a process is not generally freed to the operating system immediately an object is deleted. Is there any suggestions to decrease total memory as soon as possible?
    I tried Google Chrome, it will free memory to operating system in a short time when close existing tabs.

  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: Memory issue when close QMdiSubWindow

    The memory allocator is linked into your program, usually from glibc on Linux. In general it will hold on to all memory allocated to the process, even when freed, and satisify future requests from that pool. The operating system will only try to reclaim allocated but unused memory from processes if it needs to satisfy another request and cannot. In your case, the memory released by closing a tab should be used when you open the next. The precise dynamics of this are driven by exactly how your program allocates and deallocates memory.

    Chrome almost certainly has a customised/optimised memory allocator that deliberately manages the interaction with the operating system's free list by preallocating memory into the process in large chunks. You can provide your own memory allocator but it is usually unnecessary.

    See
    http://stackoverflow.com/questions/1...-get-reclaimed
    http://en.m.wikipedia.org/wiki/Sbrk

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

    seauniv (12th December 2014)

  4. #3
    Join Date
    Aug 2013
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Memory issue when close QMdiSubWindow

    Thanks very much!

Similar Threads

  1. Bug with QMdiSubWindow Close window flag, or am I doing this wrong?
    By MachinTrucChose in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2011, 22:49
  2. close button in twm - WM_DELETE_WINDOW issue
    By deepakn in forum Qt Programming
    Replies: 1
    Last Post: 21st July 2011, 12:57
  3. Memory full. Close some applications and try again.
    By bilalsaeed in forum Qt for Embedded and Mobile
    Replies: 7
    Last Post: 14th February 2011, 16:56
  4. Close event in QMdiSubWindow
    By bxaHj in forum Newbie
    Replies: 1
    Last Post: 26th May 2009, 21:18
  5. Close a QMdiSubwindow
    By John_P in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2008, 17:23

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.