• 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: Questions about Nib Object Retention
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about Nib Object Retention


  • Subject: Re: Questions about Nib Object Retention
  • From: an0 <email@hidden>
  • Date: Wed, 21 Oct 2009 13:38:58 +0800

So, to be a good memory-wise citizen:1. If there is only one outlet to a
top-level object from the nib owner, the outlet should have "assign"
attribute, and the nib owner is now in fact the "initial 1 retention"(which
seems reserved right for this predictable ownership)'s owner so is
responsible for the releasing. Otherwise if the outlet uses "retain" logic,
there will be a redundant retention to the top-level object so a memory
leak.
2. If there are other outlets to a top-level object from other objects, they
should use the "retain" logic to claim their share of ownership.
3. Outlets to non-top-level objects should always use the "retain" logic if
they want to claim their ownership, since there are no reserved initial
retain count for them.

Am I getting it all right?

On Wed, Oct 21, 2009 at 11:55 AM, Graham Cox <email@hidden> wrote:

>
> On 21/10/2009, at 2:40 PM, an0 wrote:
>
>  Who owns the unarchived top-level objects' initial positive retain count?
>>
>
> Nobody. That's what "no owning object" means.
>
>  Are they retained for outlet connections?
>>
>
> No, because if there is an outlet to them then they are owned.
>
>  Or are they just not autoreleased only because they are top-level,
>> regardless of whether there are any outlet connected to them?
>>
>
>
> They are not autoreleased because that would presumably cause problems for
> the users of these objects, who don't own them either. If there's an outlet
> to them, they are owned by whoever declares the outlet.
>
> As it says, "Your code is responsible for releasing these top-level
> objects".
>
> This is not the big issue it seems. Most nibs don't contain top level
> objects with no owners. For the very few that do, the objects most likely
> leak but typically that's no big deal unless you're loading the same nib
> repeatedly many times.
>
> --Graham
>
>
>


--
Hell boy is cool, but let me be healthy boy first.
_______________________________________________

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: Questions about Nib Object Retention
      • From: Kyle Sluder <email@hidden>
References: 
 >Questions about Nib Object Retention (From: an0 <email@hidden>)
 >Re: Questions about Nib Object Retention (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Child window shows up on top despite specifying NSWindowBelow
  • Next by Date: Re: Questions about Nib Object Retention
  • Previous by thread: Re: Questions about Nib Object Retention
  • Next by thread: Re: Questions about Nib Object Retention
  • Index(es):
    • Date
    • Thread