• 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: Alloc Mocks my World
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alloc Mocks my World


  • Subject: Re: Alloc Mocks my World
  • From: j o a r <email@hidden>
  • Date: Thu, 25 Aug 2005 10:59:12 +0200


On 25 aug 2005, at 10.43, Philip Dow wrote:

The very next line of code reads: int retCount = [newCell retainCount]; And what is the retain count? 3. Three! Not one. Not even two. Three. How in the world is my allocation and initialization producing a retain count of three?

<snip>

Nothing I've read about object allocation and nib ownership suggests that this code would produce an object with a retain count of three. If declaring the object owner of the nib increased the retain count, then maybe I would understand two. But in all the examples of seen, no one seems to worry that something like this is happening. The "Loading Resources" documentation doesn't mention this either. Does anyone know how the retain count hits 3 then?

This pops up every so often. What you forget is most likely the effect of autorelease. The interesting thing to monitor is the *effective* retain count, not the absolute retain count.


Don't spend time trying to track the absolute retain count. Concentrate on balancing your own retain / release events. If you suspect leaks, or other memory management problems, use the appropriate tools: NSZombie, ObjectAlloc, et.c.

j o a r



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Alloc Mocks my World
      • From: Philip Dow <email@hidden>
References: 
 >Re: refreshObject:mergeChanges: vs. stale transient (From: Frank Illenberger <email@hidden>)
 >Alloc Mocks my World (From: Philip Dow <email@hidden>)

  • Prev by Date: Alloc Mocks my World
  • Next by Date: How to draw correct underline ?
  • Previous by thread: Alloc Mocks my World
  • Next by thread: Re: Alloc Mocks my World
  • Index(es):
    • Date
    • Thread