Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

C++ Qt 102 - Memory Managment with Qt

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,806
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jan 23, 2012

Learn how to avoid memory leaks and use the QPointer class

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:
see all

All Comments (16)

Sign In or Sign Up now to post a comment!
  • I LOVE YOU!!!

  • thanks for tutorial

  • hi everyone. I want to program a antivirus, how can I do that?

  • I hope my phone won't come and hit me in the head with a all the crap I stored in it's memory...

    Thank god restarting the phone cleares it...right?...

  • @ffxme Sounds like a double delete. After manually deleting a pointer, be sure to set it to zero or NULL.

  • DON'T USE QPointer! It is unofficially deprecated by Qt and the advice on the lists is to not use it. It has issues with const correctness and forward declared types which can result in slicing. GCC will warn you of this but Microsoft's compilers will NOT!

    You're much better off using shared_ptr and weak_ptr which are standard in C++.

    Memory management really isn't hard, even with bald pointers. Modern managed languages are often very slow because they can't be as smart as the programmer.

  • ~ 5:00

    This is only the case if or because Test is a QObject, which automatically deletes its children, right? So if Test would not inherit QObject, there would still be a memory leak without calling delete on mChild, or am I wrong (as I am still in my "Learning Phase")?

  • @ffxme Google cppcheck. A very good app for finding errors

  • @DerCrossi The thing is, it only crashes 1% of the time, if I was pointing to a freed pointer you would think it would crash every time no?

  • @ffxme You might be accessing a pointer pointing to invalid data (i.e. you've freed the data the pointer points to, but continue using the pointer). I suggest you compile in debug mode and look at the stack trace when the crash/segfault happens. If you've roughly located the problem, set a break point and start stepping through the code.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more