Re: Triggering an NSTextStorage Bug
Re: Triggering an NSTextStorage Bug
- Subject: Re: Triggering an NSTextStorage Bug
- From: Timothy Wood <email@hidden>
- Date: Thu, 21 Mar 2013 08:35:15 -0700
On Mar 20, 2013, at 12:01 PM, Kyle Sluder <email@hidden> wrote:
> The reason it's limited to 19 bits is because for speed purposes
> NSParagraphStyle implements its own inline retain count rather than
> relying on NSObject's external refcount table. Which is also why you
> can't make ARC weak references to NSParagraphStyle instances. ;-)
Yikes. Usually the inline bits are used for the *low order* bits of the retain count. That is, the full retain count is something like (internal_refs + (external_refs << internal_width). But in this case NSParagraphStyle does only seem to be using the internal bits:
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
NSParagraphStyle *pg = [NSParagraphStyle defaultParagraphStyle];
for (;;) {
for (NSUInteger i = 0; i < 100000; i++)
[pg retain];
NSLog(@"%ld", [pg retainCount]);
}
return 0;
}
2013-03-21 08:32:12.689 pgref[81462:707] 100001
2013-03-21 08:32:12.691 pgref[81462:707] 200001
2013-03-21 08:32:12.693 pgref[81462:707] 300001
2013-03-21 08:32:12.695 pgref[81462:707] 400001
2013-03-21 08:32:12.696 pgref[81462:707] 500001
2013-03-21 08:32:12.698 pgref[81462:707] 75713 <---- Nooooooo!
2013-03-21 08:32:12.700 pgref[81462:707] 175713
2013-03-21 08:32:12.702 pgref[81462:707] 275713
2013-03-21 08:32:12.704 pgref[81462:707] 375713
…
-tim
_______________________________________________
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