Results 1 to 2 of 2

Thread: how does Qt handle memory allocation in the case of readAll

  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default how does Qt handle memory allocation in the case of readAll

    Suppose I have a Qfile, I call on file.readAll()
    This returns a bytearray containing the contents of the file.
    Since it does not return a pointer, you cannot delete the returned value.
    So how does Qt avoid memory leaks?
    Is there a reference counting system?

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

    Default Re: how does Qt handle memory allocation in the case of readAll

    The QByteArray contents are destroyed when the QByteArray you put them in goes out of scope. This is standard C++ behaviour and nothing specific to Qt.

Similar Threads

  1. Dynamic Memory Allocation
    By Atomic_Sheep in forum General Programming
    Replies: 2
    Last Post: 18th August 2013, 11:19
  2. memory allocation problem
    By marc2050 in forum Newbie
    Replies: 7
    Last Post: 23rd May 2011, 09:05
  3. Widget Memory Allocation
    By ArlexBee-871RBO in forum Qt Programming
    Replies: 5
    Last Post: 9th May 2010, 19:51
  4. QDrag : memory allocation
    By kghose in forum Qt Programming
    Replies: 1
    Last Post: 14th August 2008, 22:57
  5. limit memory allocation
    By magland in forum General Programming
    Replies: 10
    Last Post: 23rd March 2007, 09:21

Tags for this Thread

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.