Results 1 to 16 of 16

Thread: memory leaks detection in QT

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: memory leaks detection in QT

    Quote Originally Posted by spirit View Post
    how will delete this array?

    you don't do this.
    hmmm, not sure I understood your question. Can u be more specific?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: memory leaks detection in QT

    you create an array on the heap, but don't release memory after using this cause a memory leak about which you are talking, so you need to do the next
    Qt Code:
    1. ...
    2. char* buf=new char[10];
    3. ...
    4. delete[] buf;
    To copy to clipboard, switch view to plain text mode 
    Last edited by spirit; 28th January 2009 at 19:10.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jan 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: memory leaks detection in QT

    Quote Originally Posted by spirit View Post
    you create an array on the heap, but don't release memory after using this cause a memory leak about which you are talking, so you need to do the next
    Qt Code:
    1. ...
    2. char* buf=new char[10];
    3. ...
    4. delete buf[];
    To copy to clipboard, switch view to plain text mode 
    yes, I know this :-) I'm talking about tool that can warn me about this kind of mistakes.

    P.S. btw: "delete[] buf;" is works better
    Last edited by kompotFX; 28th January 2009 at 18:54.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: memory leaks detection in QT

    sorry, did not read carefully.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Memory Leak Detection Tool
    By navi1084 in forum Qt Programming
    Replies: 4
    Last Post: 4th November 2008, 15:44
  2. Memory leaks..
    By santhoshv84 in forum Qt Programming
    Replies: 2
    Last Post: 28th August 2008, 19:28
  3. Memory leak Detection using Valgrind
    By joseph in forum Qt Programming
    Replies: 4
    Last Post: 27th March 2008, 07:34
  4. Memory leaks when read/write to DOM
    By SailinShoes in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2008, 11:51
  5. memory leaks
    By Fastman in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2008, 08:00

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.