• 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 Collection Docs Puzzle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage Collection Docs Puzzle


  • Subject: Re: Garbage Collection Docs Puzzle
  • From: John Engelhart <email@hidden>
  • Date: Tue, 26 Jan 2010 18:39:17 -0500

On Tue, Jan 26, 2010 at 4:51 PM, Sean McBride <email@hidden>wrote:

> On 1/25/10 4:49 PM, Robert Clair said:
>
> >The garbage collection docs section on the interior pointer issue shows
> >this example:
> >
> >NSData *myData = [someObject getMyData];
> >[myData retain];
> >const uint8_t *bytes = [myData bytes];
> >NSUInteger offset = 0, length = [myData length];
> >
> >while (offset < length) {
> >  // bytes remains valid until next message sent to myData
> >}
> >[myData release];
>
> My favourite solution is this one:
> <http://lists.apple.com/archives/Objc-language/2009/Mar/msg00060.html>
>
> It's been working well for me.


I've gone the 'volatile' route:

NSData * volatile myData = [someObject getMyData];
// [myData retain];  Removed, no need w/ volatile.
const uint8_t *bytes = [myData bytes];
NSUInteger offset = 0, length = [myData length];

while (offset < length) {
  // bytes remains valid until next message sent to myData
}
// [myData release]; Removed, no need w/ volatile.
_______________________________________________

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 Collection Docs Puzzle (From: Robert Clair <email@hidden>)
 >Re: Garbage Collection Docs Puzzle (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: Need help figuring out poor Core Data performance
  • Next by Date: AppleEvent memory leak
  • Previous by thread: Re: Garbage Collection Docs Puzzle
  • Next by thread: Re: Garbage Collection Docs Puzzle
  • Index(es):
    • Date
    • Thread