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

Re: Inconsistent Memory Management Rules


  • Subject: Re: Inconsistent Memory Management Rules
  • From: Sherm Pendley <email@hidden>
  • Date: Wed, 16 Apr 2003 01:54:12 -0400

On Tuesday, April 15, 2003, at 11:37 PM, Denis Stanton wrote:

So the rules for me are:

I think you're over-complicating matters a bit. It's really quite simple - if you create an object with +alloc, -copy, or +new, then sooner or later you'll need to either release or autorelease it; if you don't, it will leak.

If you didn't create it with one of those methods, then releasing it is not your responsibility.

1) You have to use [[NSxxxxxx alloc] init], except where there is a convenience method for NSxxxxxx

I'd hesitate to ever say "you have to" with respect to the choice of an initializer method vs. a convenience method. There are generally a number of alternatives that will work in any given situation. Using an initializer simply means you're responsible for releasing the object at some point.

2). Convenience methods for declaring objects have the form [NSxxxxxx initmethod]

No, convenience methods are anything other than +alloc, -copy, or +new. They may be either class or instance methods.

3). Such convenience methods will already include autorelease.

Yes.

4). Otherwise an alloc must be followed (eventually) by release

Or -autorelease.

sherm--

C programmers never die - they're just cast into void.
_______________________________________________
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.

References: 
 >Re: Inconsistent Memory Management Rules (From: Denis Stanton <email@hidden>)

  • Prev by Date: Re: Newbie: Current Apps Directory
  • Next by Date: Re: Inconsistent Memory Management Rules
  • Previous by thread: Re: Inconsistent Memory Management Rules
  • Next by thread: Re: Inconsistent Memory Management Rules
  • Index(es):
    • Date
    • Thread