• 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: More GC. Now with NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More GC. Now with NSData


  • Subject: Re: More GC. Now with NSData
  • From: Alastair Houghton <email@hidden>
  • Date: Mon, 26 Nov 2007 18:00:46 +0000

On 26 Nov 2007, at 17:56, Sherm Pendley wrote:

Doesn't -dataWithBytesNoCopy:length:freeWhenDone: do the Right Thing (tm) with respect to marking the returned NSData instance as non- collectible when the third param is NO?

IMHO, it should, and if it doesn't, that sounds like a bug.

No, because the NSData instance is still perfectly collectable. The underlying data isn't, but that's not the problem here. The problem is that the underlying NSData (the one that actually holds the memory) can be garbage collected if the last reference to it disappears, which can easily happen in code like this because the GC ignores interior pointers. i.e. the pointers that the new NSDatas keep to their data aren't enough to keep the original NSData alive because they don't point to the original NSData object itself.


Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

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


References: 
 >More GC. Now with NSData (From: Paul Sargent <email@hidden>)
 >Re: More GC. Now with NSData (From: Alastair Houghton <email@hidden>)
 >Re: More GC. Now with NSData (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: More GC. Now with NSData
  • Next by Date: Re: Loading View in Placeholder upon startup
  • Previous by thread: Re: More GC. Now with NSData
  • Next by thread: Re: More GC. Now with NSData
  • Index(es):
    • Date
    • Thread