• 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: Triggering an NSTextStorage Bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Triggering an NSTextStorage Bug
      • From: Seth Willits <email@hidden>
References: 
 >Triggering an NSTextStorage Bug (From: Seth Willits <email@hidden>)
 >Re: Triggering an NSTextStorage Bug (From: Andy Lee <email@hidden>)
 >Re: Triggering an NSTextStorage Bug (From: Seth Willits <email@hidden>)
 >Re: Triggering an NSTextStorage Bug (From: Seth Willits <email@hidden>)
 >Re: Triggering an NSTextStorage Bug (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Global (all-user) preferences for an application
  • Next by Date: Re: How to get all the path of an application present on the disk
  • Previous by thread: Re: Triggering an NSTextStorage Bug
  • Next by thread: Re: Triggering an NSTextStorage Bug
  • Index(es):
    • Date
    • Thread