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

Xcode 4 Memory Leak Instruments Part 2 (The Solution)

Loading...

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

Uploaded by on May 25, 2011

In Part 1 I've investigated why the Leaks instrument doesn't catch a leak. This video was a direct result of one of the discussions over at the fantastic Facebook iOS Developers Group (http://gcx.cx/fbios).

In this part, we're solving the "mystery".

Category:

Science & Technology

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:
see all

All Comments (3)

Sign In or Sign Up now to post a comment!
  • ...To prevent the leak you could implement a method that is called before you nil your array that loops through eacht object in the array and releases it (thus decreasing retain count to 1). Then when you nil your array the retain count is decreased again (becoming 0 and deallocing the object).

    So, instruments wouldn't know if youre going to release the objects before niling its references and cant display the "leak" before that is done. Because only after that, the leak occurs.

  • Sorry, I know this posting is older but I just found it and wanted to comment on it:

    As I understand a leaking object occurs when an object that is retained in memory loses all its references. So until you nil your array, the references arent lost and no leaking occurs. Also, in your for-loop I think you mention the retain count being 1. I think the retain count is 2 (alloc adds +1 and addObject to your array adds +1).

  • Awesome!

    Now I finally understand why leaking 'doesn't work' :)

    Great tuto!

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