• 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
Is an just allocated object allways set to autorelease? What about my subclasses?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is an just allocated object allways set to autorelease? What about my subclasses?


  • Subject: Is an just allocated object allways set to autorelease? What about my subclasses?
  • From: Alexandre Aybes <email@hidden>
  • Date: Fri, 21 Dec 2001 12:31:00 +0100

Hi there,
I am tracking down the (gigantic) memory leaks in my application (I've been doing too much java for too long ;)) And since I am fairly new to Cocoa/ObjC and I would like to know if all the basic Cocoa objects (the ones from the AppKit) are set to autorelease when I call "[[XXX alloc] init]". And another question when I create my own class, should I do:

- (id)init
{
if (self = [super init])
{
// do my initialization
}
return self;
}

or should I do:

- (id)init
{
if (self = [super init])
{
// do my initialization
}
return [self autorelease];
}

I am confused because all my objects seem to have a too high retain count... :<
Also if the fact that they are autoreleased depends on the object, where can I find the docs for that?

Thanks,
Alex.


  • Follow-Ups:
    • Re: Is an just allocated object allways set to autorelease? What about my subclasses?
      • From: Ondra Cada <email@hidden>
    • Re: Is an just allocated object allways set to autorelease? What about my subclasses?
      • From: "John C. Randolph" <email@hidden>
    • Re: Is an just allocated object allways set to autorelease? What about my subclasses?
      • From: Max Horn <email@hidden>
  • Prev by Date: Re: Silly question
  • Next by Date: ObjectAlloc, where do I see the retain count?
  • Previous by thread: Re: cocoa-dev digest, Vol 1 #999 - 7 msgs
  • Next by thread: Re: Is an just allocated object allways set to autorelease? What about my subclasses?
  • Index(es):
    • Date
    • Thread