• 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: Bug in CF/NSString's no-copy constructors (was Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in CF/NSString's no-copy constructors (was Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful)


  • Subject: Re: Bug in CF/NSString's no-copy constructors (was Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful)
  • From: Michael Tsai <email@hidden>
  • Date: Wed, 6 Feb 2008 11:46:25 -0500

On Feb 6, 2008, at 10:55 AM, Alastair Houghton wrote:

I'll just add, publicly, that I think this probably is a bug in CFString that John has found here. That is, I don't see why CFString's pointer shouldn't be traced by the collector in this case (it doesn't appear to be; certainly when I try it the backing buffer is released). The problem also occurs with NSString's - initWithBytesNoCopy:length:encoding:freeWhenDone: et al.

I don't think this is a bug. The NSString and CFString APIs do not indicate that they treat the bytes as scanned memory. In fact, when you pass in kCFAllocatorNull you are telling CFString that you "assume responsibility for deallocating the buffer." At the end of - someMethod, you haven't saved a __strong reference to the buffer, so the collector is allowed to free it.


--Michael


_______________________________________________

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: Bug in CF/NSString's no-copy constructors
      • From: Alastair Houghton <email@hidden>
References: 
 >Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful (From: John Engelhart <email@hidden>)
 >Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful (From: Alastair Houghton <email@hidden>)
 >Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful (From: John Engelhart <email@hidden>)
 >Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful (From: Alastair Houghton <email@hidden>)
 >Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful (From: John Engelhart <email@hidden>)
 >Bug in CF/NSString's no-copy constructors (was Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful) (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: Transferring data between Python and Cocoa (maybe a newbie question)
  • Next by Date: Re: Apples's code examples... Poor coded or it is just me?
  • Previous by thread: Bug in CF/NSString's no-copy constructors (was Re: Use of Mac OS X 10.5 / Leopards Garbage Collection Considered Harmful)
  • Next by thread: Re: Bug in CF/NSString's no-copy constructors
  • Index(es):
    • Date
    • Thread