Results 1 to 2 of 2

Thread: What is the best way and place to deallocate the memory?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default What is the best way and place to deallocate the memory?

    What is the best way and best place to deallocate memory in Qt? Is the destructor is a good choice to deallocate the memory?
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: What is the best way and place to deallocate the memory?

    What is the best way and best place to deallocate memory in Qt?
    Not only in Qt - but in general:
    When the allocated memory is no longer needed.
    s the destructor is a good choice to deallocate the memory?
    The destructor is the LAST place/time at which an object can free the momory it allocated.
    But you should not wait that long if any given chunk of memory is not needed any more - you should free any memory as soon as you can.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QGridLayout place new widgets at top
    By rouge in forum Newbie
    Replies: 7
    Last Post: 6th October 2011, 08:06
  2. Replies: 3
    Last Post: 21st April 2009, 05:25
  3. QPixmaps don't seem to deallocate from memory(solved)
    By timothy.crosley in forum Qt Programming
    Replies: 11
    Last Post: 15th August 2007, 21:59
  4. How to place contextmenu in QGraphicsScene?
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 14th January 2007, 16:04

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.