Re: Newbie question: how to release an object that has been autoreleased
Re: Newbie question: how to release an object that has been autoreleased
- Subject: Re: Newbie question: how to release an object that has been autoreleased
- From: Chris Ridd <email@hidden>
- Date: Wed, 22 Sep 2004 13:48:09 +0100
On 22/9/04 8:29 am, mmalcolm crawford <email@hidden> wrote:
>
> On Sep 21, 2004, at 11:58 PM, Scott Stevenson wrote:
>
>>> 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.
>> Why do you need it released immediately? The fact that you're running
>> into this at all suggests you're making things more complicated than
>> they need to be.
One reason might be that it contains some sort of secret information (eg
decrypted private key material) that you really don't want hanging around in
memory.
In that sort of case, I'd have a method which overwrote the contents of the
buffer with random data, and send the buffer that message before releasing
or autoreleasing it.
Cheers,
Chris
_______________________________________________
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