• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Tracking the retain count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tracking the retain count


  • Subject: Re: Tracking the retain count
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 18 May 2015 08:11:18 +0000

On May 17, 2015, at 23:59 , Britt Durbrow <email@hidden> wrote:
>
> My understanding of retainCount is that it’s basically considered “taboo” because trying to use it without knowing exactly what you are doing tends to lead to pitfalls, and most people looking at it tend to think it means something that it doesn't.

You’re right to be cautious, but you’ve come to the wrong conclusion. From OS X 10.0 to 10.5 (and beyond for numerous apps), memory was managed manually with ‘retain’ and ‘release’, and that certainly is “using” the retain count.

What was frowned upon was reckless *reasoning* about retain counts: “If the retain count is such and such, and I do so and so, then XYZ will happen”. Those sorts of arguments tended to blow up in peoples’ faces**.

It is, however, valid to increment the retain count of a valid (that is, live) object, and to reason that the object will stay alive at least until you decrement the retain count. This is sufficient for your scenario.


** For example: "If the retain count is 1, and I decrement it, the object will be deallocated.” This is incorrect reasoning, because any code that checks and decrements the retain count is subject to side effects that affect the outcome.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Tracking the retain count
      • From: Britt Durbrow <email@hidden>
References: 
 >Tracking the retain count (From: Britt Durbrow <email@hidden>)
 >Re: Tracking the retain count (From: Jonathan Hull <email@hidden>)
 >Re: Tracking the retain count (From: Britt Durbrow <email@hidden>)

  • Prev by Date: Re: Tracking the retain count
  • Next by Date: Re: How to draw a NSView on top of a WebView and don't get overriden trying
  • Previous by thread: Re: Tracking the retain count
  • Next by thread: Re: Tracking the retain count
  • Index(es):
    • Date
    • Thread