• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie question: how to release an object that has been autoreleased
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Newbie question: how to release an object that has been autoreleased (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: NSTimer questions
  • Next by Date: Re: How do folks group things as per Address Book?
  • Previous by thread: Re: Newbie question: how to release an object that has been autoreleased
  • Next by thread: scrollToPoint vs scrollRectToVisible
  • Index(es):
    • Date
    • Thread