• 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: Garbage collector vs variable lifetime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage collector vs variable lifetime


  • Subject: Re: Garbage collector vs variable lifetime
  • From: George Stuart <email@hidden>
  • Date: Fri, 6 Jun 2008 19:51:49 -0500

On Jun 6, 2008, at 7:05 PM, Ricky Sharp wrote:


On Jun 6, 2008, at 6:42 PM, Bill Bumgarner wrote:


Sorry -- let me clarify. If the <data> was either released in a different thread or if <data> were explicitly released in the above code, then you would see the same crash. I didn't mean to imply that <data> would be released under non-GC without some explicit action being taken.


Under GC, the situation isn't quite so clear.


That makes perfect sense. Sorry that I glossed over the 'other thread' bit.


What about using the data pointer directly in the loop? Would this prevent the GC thread from freeing that memory early? This sends a message to the data object at each iteration, so not as optimal as pointer arithmetic I suppose...


	NSData* data = <get it from somewhere>;
	NSUInteger count = [data length];
	for (NSUInteger i = 0; i < count; i++)
		[data getBytes:&something range:NSMakeRange(i, 1)];

Cheers,
George
_______________________________________________

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: 
 >Garbage collector vs variable lifetime (From: Quincey Morris <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Bill Bumgarner <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Ricky Sharp <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Bill Bumgarner <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: Core Data Questions
  • Next by Date: Re: OK on Enter, not Return
  • Previous by thread: Re: Garbage collector vs variable lifetime
  • Next by thread: Re: Garbage collector vs variable lifetime
  • Index(es):
    • Date
    • Thread