• 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
-retain and -release Questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-retain and -release Questions


  • Subject: -retain and -release Questions
  • From: Jerry Krinock <email@hidden>
  • Date: Sat, 06 Mar 2004 23:20:08 -0800

Hi,

From a C++ background, I'm learning to use -retain and -release with some
difficulty. I have difficulty understanding much of the document "Object
Ownership and Disposal":

file:///Developer/Documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/ObjectO
wnership.html#//apple_ref/doc/uid/20000043/BEHDEDDB

Now, I'm learning when to use -retain OK, because of the big fat crash which
occurs whenever I omit one. But -release is more tricky.

Generally, if I create (-alloc and -init) an object for temporary use only
within one method, I believe I need to -release this object before the
method returns. This is in contrast to C++, where objects are automatically
deleted when they go out of scope. Is this correct?

Am I correct in saying that the only bad effect of omitting a -release or
-autorelease message is that it causes a memory leak?

Is there a tool to check my Obj-C/Cocoa app for such memory leaks? (I use
CodeWarrior, but of course I have XCode available, if there is anything
built to them).

Thanks

Jerry Krinock
San Jose, CA USA
_______________________________________________
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: -retain and -release Questions
      • From: Larry Fransson <email@hidden>
    • Re: -retain and -release Questions
      • From: Clark Cox <email@hidden>
    • Re: -retain and -release Questions
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: PB and IB no longer launch
  • Next by Date: Re: -retain and -release Questions
  • Previous by thread: PB and IB no longer launch
  • Next by thread: Re: -retain and -release Questions
  • Index(es):
    • Date
    • Thread