Re: Garbage collector vs variable lifetime
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