Re: End Of Method Releasing Order?
Re: End Of Method Releasing Order?
- Subject: Re: End Of Method Releasing Order?
- From: Shawn Erickson <email@hidden>
- Date: Mon, 1 Jun 2009 18:33:44 -0700
On Mon, Jun 1, 2009 at 6:05 PM, WT <email@hidden> wrote:
> I don't think so. Releasing objects merely decreases their retain count.
> It's up to the Obj-C runtime system to figure out in what order to actually
> free the memory allocated for those objects. In other words, we are not the
> ones deciding how and when to deallocate memory allocated for objects. We
> merely indicate to the runtime system that we're no longer interested in a
> given object at a given point in the program runtime execution flow. What
> happens to the object after that is not up to us.
To be clear in a non-GC environment...
The -release message that causes the retain count to hit zero sends a
-dealloc message to self. In -dealloc memory is freed using runtime
methods. Not really the runtime deciding anything, it is the
implementation of NSObject that does this. Note some classes modify
-release (and/or -dealloc) to prevent deallocation in some situations
but it is the implementation of the class that is doing that.
The order of releases can matter assuming the classes involved have
some interdependencies not already managed by retains. Usually such
interdependencies will be managed by retains (normal memory contract
helps ensure this) so strict ordering of releases, etc. is not needed.
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden