• 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: Cocoa - Naive questions about memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa - Naive questions about memory


  • Subject: Re: Cocoa - Naive questions about memory
  • From: Yann Bizeul <email@hidden>
  • Date: Mon, 5 May 2003 00:21:53 +0200

Hi,

First of all, read this documentation at stepwise :
http://www.stepwise.com/Articles/Technical/MemoryManagement.html

It is well explained and detailed with good examples.

Is 'the end of the event cycle' when a program completes one time through
the loop or when the program exits?
at the end of the cycle


In "Object Ownership and Disposal" we see:

Cocoa therefore sets this policy: If you create an object (using alloc,
allocWithZone:, or new) or copy an object
(using copy, copyWithZone:, mutableCopy,or mutableCopyWithZone:), you alone
are responsible for releasing it.
If you did not directly create or copy the object, you do not own it and
should not release it.

Then there is sample code that appears to do the opposite:

- (void)setMainSprocket:(Sprocket *)newSprocket
{
[mainSprocket autorelease];
mainSprocket = [newSprocket retain]; /* Claim the new Sprocket. */
return;
}

Why is it necessary to call autorelease for he object to which mainSprocket
pointed before setMainSprocket is
invoked. If there is another pointer to that object in another method,
won't that there be a call in that other method
to release the object using the other pointer. If there isn't another
pointer, by what mechanism could the memory
management system be able to dectect that the object is no longer used?
Somebody helped for that :-)
_______________________________________________
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: 
 >Cocoa - Naive questions about memory (From: Danny Swarzman <email@hidden>)

  • Prev by Date: Re: Cocoa - Naive questions about memory
  • Next by Date: Re: monitoring table selection
  • Previous by thread: Re: Cocoa - Naive questions about memory
  • Next by thread: Re: Cocoa - Naive questions about memory
  • Index(es):
    • Date
    • Thread