Re: ARC Retain Cycles
Re: ARC Retain Cycles
- Subject: Re: ARC Retain Cycles
- From: Alex Zavatone <email@hidden>
- Date: Mon, 21 Apr 2014 10:53:18 -0400
On Apr 21, 2014, at 10:34 AM, Andy Lee wrote:
> On Apr 21, 2014, at 8:27 AM, Dave <email@hidden> wrote:
>> Also, when I did this, I left the property attributes as “retain” and “assign”, I’m wondering if it would be better to change them to “strong” and “weak” ? Although, AFAIK this shouldn’t make a difference?
>
> For object properties, "strong" is a synonym for "retain", but "assign" is different from "weak". Weak properties are automatically set to nil when the object they reference goes away. If you use "assign" for an object property, it will not be automatically nil'ed and you may end up with a garbage pointer.
>
> "weak" is not supported in 10.6 or 10.7, I forget which. If you need to support an OS version that supports ARC but not "weak", you should use the qualifier "unsafe_unretained" rather than "assign". It behaves the same, but it expresses intention better, plus you can later do a global replace to use "weak" when you decide to drop support for that old OS. In this case it's up to you to nil out that object property at the appropriate time.
In that case, is it any significant overhead in simply using strong?
In a case of rapidly allocating objects that are strongly linked and weakly linked, are there any tests that have been published to show the overall impact on performance, memory overhead, etc?
I've got time to perform some simple tests, but no time to do anything terribly robust.
Are any of you aware of anything out there?
Cheers,
- Alex
_______________________________________________
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