• 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: Memory Management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Management


  • Subject: Re: Memory Management
  • From: Chris Purcell <email@hidden>
  • Date: Tue, 29 Jul 2003 17:15:01 +0100

- (void)setName:(NSString *)newNamemet {
[newName retain];
[_name release];
_name = newName;
}

This is fine.

Thread safe ?

No, obviously not. It would need a lock around it, if you were to do
it that way. The question then becomes: what's faster, a lock or an
autorelease? In most situations an autorelease, I would think, since
it would be a once-off, versus potentially having to acquire the lock
many times. Unless of course your value changes far more frequently
than you access it, in which case I suppose a lock might be faster.

You would always need a lock around it. Autorelease is not magic. It certainly won't get you thread safety.

But then, trying to make accessors thread-safe is almost surely not useful, as per the logic I proposed in my previous rant :)

Kritter out
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Memory Management
      • From: Wade Tregaskis <email@hidden>
  • Prev by Date: Re: cocoa-dev digest, Vol 2 #2711 - 14 msgs
  • Next by Date: Re: Memory Management
  • Previous by thread: Re: Memory Management
  • Next by thread: Re: Memory Management
  • Index(es):
    • Date
    • Thread