• 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: AutoReleasePool question.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AutoReleasePool question.


  • Subject: Re: AutoReleasePool question.
  • From: Daniel Hazelbaker <email@hidden>
  • Date: Mon, 27 Mar 2006 14:36:43 -0800

I've learned from experience that anytime you create a thread, just create an autorelease pool (and release it occasionally). There is very little overhead to releasing an empty autorelease pool and it saves you from wondering when some method you call might try to use one.

I normally do something like:

(void)myThread:(void *)data
{
    NSAutoreleasePool *pool;
    NSDate *releaseDate;

    //
    // Create the initial pool with a 15 second timeout
    //
    pool = [[NSAutoreleasePool alloc] init];
    releaseDate = [NSDate dateWithTimeIntervalSinceNow:15];

    for (; !done;)
    {
        /* Process */

//
// If the pool is ready to expire, then release it and create a new one.
//
if ([releaseDate timeIntervalSinceNow] <= 0)
{
[pool release];
pool = [[NSAutoreleasePool alloc] init];
releaseDate = [NSDate dateWithTimeIntervalSinceNow:15];
}
}


    [pool release];
}

Note: I did not try to compiile this to check for syntax errors, and I have a tendency to get confused on the "direction" of time with NSDates, but this will make sure each thread has an autorelease pool and it will make sure that it never is around longer than 15 seconds. Personally, I wish I could make a call like [pool sizeOfMemory] to see how "big" the pool is and release after X MB, but alas....

Daniel

On Mar 25, 2006, at 7:12 PM, John Draper wrote:

Hi,

I'm getting a lot of these messages...

2006-03-25 18:41:36.716 newSipTestApp[2011] *** _NSAutoreleaseNoPool (): Object 0x6bdd890 of class NSCFNumber autoreleased with no pool in place - just leaking
2006-03-25 18:41:36.716 newSipTestApp[2011] *** _NSAutoreleaseNoPool (): Object 0x6bddb40 of class NSConcreteValue autoreleased with no pool in place - just leaking
2006-03-25 18:41:36.716 newSipTestApp[2011] *** _NSAutoreleaseNoPool (): Object 0x6bddb80 of class NSIdEnumerator autoreleased with no pool in place - just leaking
2006-03-25 18:41:36.727 newSipTestApp[2011] *** _NSAutoreleaseNoPool (): Object 0x6bddb40 of class NSConcreteValue autoreleased with no pool in place - just leaking


How do I find out which objects these are... Note the addresses of the object instances
are given, but how do I find out which ones there are?


I'm using X-Code 1.5, and I don't have any of these objects in my application, and yet it is indicating
these are "leaking".


Is there any tips, app notes, and other references that can explain this.
I am doing a lot of Mixing of C++ objects with Objective C objects.


How can I find out where to put these statements.?

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   < some code >
[pool release];

I am calling and managing a lot of threads, but they are C++ threads. Not much
under control of Cocoa. But am I supposed to wrap this above code in the C++ threads?
If so, what part of the thread? The part that gets called repeatedly, or the
part the initializes the thread... IE: Before initializing...


NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

And calling....

[pool release];

When thread is deleted... I'm not sure... but I'm getting thousands of
these messages above.


How can I display a list of Autorelease pools that are active in my application
using X-code 1.5?


Can someone please point me to an App Note that can help me out?
I googled for this information and amazed to find that a LOT of people
are asking the same questions, but I found NO answers on any of the google
finds. HELP!!!


john
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40highdesertchurch.com


This email sent to email@hidden



_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >AutoReleasePool question. (From: John Draper <email@hidden>)

  • Prev by Date: Debugging on Intel
  • Next by Date: porting to Xcode, weak linking and other fun stuff...
  • Previous by thread: AutoReleasePool question.
  • Next by thread: Re: AutoReleasePool question.
  • Index(es):
    • Date
    • Thread