Newbie question: how to release an object that has been autoreleased
Newbie question: how to release an object that has been autoreleased
- Subject: Newbie question: how to release an object that has been autoreleased
- From: James Bucanek <email@hidden>
- Date: Tue, 21 Sep 2004 20:31:32 -0700
Greetings,
I'm fairly new to Cacoa programming and am in the process of creating my first major application. I've got a few basic memory management questions that I can't seemed to find the answers to in the documentation.
Second question: I have an object that has been init'd then autoreleased. How do I destroy it immediately?
Example:
I have a pool of buffers. One message in that buffer pool creates a new buffer object. Like a good Cocoa programmer, I autorelease the object before I return it.
- (Buffer*)bufferFromPool
{
return ( [[[Buffer alloc] initWithMagic] autorelease] );
}
The client code uses the buffer, but now I want to destroy it immediately after I'm done with it. I can't release it because it's already been autoreleased.
I guess I'm asking if there is a way to remove an object from an autorelease pool so I can "undo" the autorelease and release it directly?
I know I could create a new NSAutoreleasePool just for this one object -- but gee, that seems like a lot of overhead just to release a buffer.
Thanks,
James
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden