• 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: Paul Sargent <email@hidden>
  • Date: Mon, 26 Nov 2007 20:38:10 +0000


On 26 Nov 2007, at 17:44, Alastair Houghton wrote:

On 26 Nov 2007, at 17:20, Paul Sargent wrote:

My question is this, I've created these NSDatas without copying the bytes, so have I put myself in a position where the garbage collector could release the memory beneath them if the original fullDataDump NSData was released?

Yes. The garbage collector doesn't support interior pointers. You need to keep the original object around by holding on to a reference to it until you're done with all of your data objects.


A better approach to the problem would be to use NSData's - subdataWithRange: method; that will avoid having to do pointer arithmetic and will also avoid entirely the problem with the garbage collector.

Ahh, Thanks. Still not 100% familiar with all the functionality available.


Just to be clear, -subdataWithRange will make a copy of the data into it's own buffer, which the new NSData will own. Hence it'll be safe. Right?


_______________________________________________

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: More GC. Now with NSData
      • From: Alastair Houghton <email@hidden>
References: 
 >More GC. Now with NSData (From: Paul Sargent <email@hidden>)
 >Re: More GC. Now with NSData (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Core Data and RDBs
  • Next by Date: Re: More GC. Now with NSData
  • Previous by thread: Re: More GC. Now with NSData
  • Next by thread: Re: More GC. Now with NSData
  • Index(es):
    • Date
    • Thread