I am a newbie to Cocoa Memory Management (have been using GC so far),
and I'd like to make sure that my understanding is correct.

Let's assume, for the sake of simplicity, that I don't explicitly
create nested auto-released pools, don't detach new threads, use Cocoa
and AppKit etc., and rely on the framework to create the autorelease
pools for me.

- If my understanding is correct, the auto-release pool is a
relatively short-lived object, that is created at the beginning of
processing each event from the run loop (e.g. a mouse down event) and
disposed on returning back to the run loop. Correct?

- While the auto-release pool exists, it's simply stores all
references to all objects that received -autorelease during processing
the event, correct?

- The auto-release pool does NOT release any objects immediately after
exiting a "declaration scope" (going out of curved brackets {} -
function, cycle, condition etc.). All these objects keep living until
the auto-release pool gets released itself, correct?  In this way
auto-release pools have nothing in common with C++ smart pointers,
that are allocated in the stack memory and automatically call object
destructor on exiting the scope where they were declared. Is this
correct?

- It follows that the actual releasing of objects registered in the
auto-release pool is deferred until the entire call stack is unfolded
back and the control passes to the next event. In this regard,
auto-release pools remind me the garbage collector, where the time of
deallocation is also somewhat indeterminate.

Thanks.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to