• 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
Newbie question: how to release an object that has been autoreleased
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Newbie question: how to release an object that has been autoreleased
      • From: Scott Stevenson <email@hidden>
  • Prev by Date: Newbie question: autorelease sends autorelease
  • Next by Date: Re: How do folks group things as per Address Book?
  • Previous by thread: Re: Newbie question: autorelease sends autorelease
  • Next by thread: Re: Newbie question: how to release an object that has been autoreleased
  • Index(es):
    • Date
    • Thread