Re: Memory management question
Re: Memory management question
- Subject: Re: Memory management question
- From: Ondra Cada <email@hidden>
- Date: Wed, 24 Mar 2004 23:36:54 +0100
Randall,
On Wednesday, Mar 24, 2004, at 23:02 Europe/Prague, Randall Meadows
wrote:
[[someObject retain] release];
When an object gets deallocated, is it then set to nil?
Never. You do that yourself when appropriate.
In the above sample, is then "someObject" == nil?
Besides, in the above sample, the object is not, repeat *NOT*
deallocated. Quite the contrary: its lifespan is (potentially) expanded
so that it exists *at least* till the current autorelease pool is freed.
Or does that variable contain an invalid (unallocated) memory address,
as would a similar pointer that has been free'd in POC (plain ol' C)?
In cases you truly release the object, ie. the simplest
[someObject release];
it is *exactly so*. If you forget to nil the variable, you are in for a
nasty surprise. Not only the app may crash: that's the better case.
Worse, another object may occupy the address meantime!
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.