• 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: new to memory mgmt
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new to memory mgmt


  • Subject: Re: new to memory mgmt
  • From: pmcurry <email@hidden>
  • Date: Sun, 15 Feb 2004 14:15:15 -0800

Ah... how the intricate folds of memory management reveal themselves so slowly!
Somehow, I was under the impression I had to create an NSAutoreleasePool within any method where I would want to autorelease an object I created.

Thanks.
-Phil

On Feb 15, 2004, at 1:54 PM, Louis C. Sacha wrote:


Hello...

I thought I had read somewhere that NSAutoreleasePools were expensive so I've been trying to only use them in a situation where I create an object within a function that I want to use as the return value. Then I create a pool in the function and auto release the object just before returning it. In your example, how can you tell at what point execution goes back to NSApplicationMain()?

You wouldn't want to _create_ an autorelease pool in this situation. If you just want to return an autoreleased value, you just send it the autorelease message, and it automatically uses the current existing NSAutoreleasePool.

You might want to take a look at:
http://www.stepwise.com/Articles/Technical/MemoryManagement.html (the sections "Temporary Obejcts" and "Gory Autorelease Details")
and
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/ index.html (there is an article on autorelease pools)

Hope that helps,

Louis
_______________________________________________
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: new to memory mgmt
      • From: Nick Zitzmann <email@hidden>
References: 
 >new to memory mgmt (From: pmcurry <email@hidden>)
 >Re: new to memory mgmt (From: Troy Dawson <email@hidden>)
 >Re: new to memory mgmt (From: pmcurry <email@hidden>)
 >Re: new to memory mgmt (From: "Louis C. Sacha" <email@hidden>)

  • Prev by Date: Re: ANN: Doxygen for MacOS X with Objective-C support
  • Next by Date: Re: new to memory mgmt
  • Previous by thread: Re: new to memory mgmt
  • Next by thread: Re: new to memory mgmt
  • Index(es):
    • Date
    • Thread