Re: [[object autorelease] release]
Re: [[object autorelease] release]
- Subject: Re: [[object autorelease] release]
- From: Brant Vasilieff <email@hidden>
- Date: Tue, 2 Oct 2001 11:13:42 -0700
On Tuesday, October 2, 2001, at 07:05 AM, cocoa-dev-
email@hidden wrote:
I think the original question was why does it crash when you release
an autorelease object. I suggest, along with others that
NSAutoreleasePool check to see if an object in its pool has already
been released before it releases it. I see no problem with this, as
the functions to check if an object has been freed exists, and in
fact, you can make it ok to release an autorelease object if you set
NSAutoreleaseFreedObjectCheckEnabled to true as an environmental
variable, or call
[NSAutoreleasePool enableFreedObjectCheck:YES];
then it should not crash if you release an autoreleased object if I
am reading the headers correctly, but unfortunately it doesn't seem
to work.
The problem with that test, is it only works in debug, if you've told it
not to free deallocated objects. Objects that are freed are marked as
dead, and further attempts to free them fail. However, you can't run
very long this way, as you chew up memory. Otherwise, the test is
unreliable, because the objects memory address could be reallocated to
another object instead, and return that the object was valid when it
shouldn't have been.
Cheers,
Brant