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

More GC. Now with NSData


  • Subject: More GC. Now with NSData
  • From: Paul Sargent <email@hidden>
  • Date: Mon, 26 Nov 2007 17:20:11 +0000

Thanks Joar for answering my last one.

I'm doing some fairy low level data interpretation, and using NSData to make my life a bit easier.

I have an NSData that contains the complete set of data called fullDataDump. I walk through this, partitioning it up into sub-blocks with code something like this:

    fullData = [fullDataDump bytes];

while (currentAddress < finalAddress) {
length = fullData[0];
NSData newRecord = [NSData dataWithBytesNoCopy:(void *) (fullData + currentAddress) length:length freeWhenDone:NO]];
[rawDives addObject:newRecord];
}


i.e. creating an array of NSDatas that point into the same memory space as the original.

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?

I'm thinking this might happen because the new NSDatas will have pointers into the middle of the original memory allocation, rather than the beginning.
_______________________________________________


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>
  • Prev by Date: CoreData adding data without using a UI
  • Next by Date: Re: [ABRecord setValue:forProperty:] with custom property?
  • Previous by thread: Re: CoreData adding data without using a UI
  • Next by thread: Re: More GC. Now with NSData
  • Index(es):
    • Date
    • Thread