Question: I'm building an iPhone application where I detach some threads to do long-running work in the background so as not to hang the UI. I understand that threads need NSAutoreleasePool instances for memory management. What I'm not sure about is if the threaded method calls another method - does that method also need an NSAutoreleasePool?

Example code:

```
- (void)primaryMethod {
    [self performSelectorInBackground:@selector(threadedMethod) withObject:nil];
}

- (void)threadedMethod {
    NSAutoreleasePool *aPool = [[NSAutoreleasePool alloc] init];

    // Some code here

    [self anotherMethod];

    // Maybe more code here

    [aPool drain];
}

- (void)anotherMethod {
    // More code here
}
```

The reason I ask is I'm receiving errors that objects are being autoreleased with no pool in place, and are "just leaking."

I've seen other questions where people didn't have autorelease pools in place at all, and I understand why an autorelease pool is needed. I'm specifically interested in finding out whether an autorelease pool created in (in this example) `threadedMethod` applies to objects created in `anotherMethod`.

Answer: 
To answer your question, yes, anotherMethod is using the NSAutoreleasePool you created in threadedMethod, and anything you autorelease there will be released when aPool is released/drained.

So it is unlikely that your error is stemming directly from this code (unless there is more going on).

Put a break point on \_NSAutoreleaseNoPool (add it by name in the Breakpoints window) and run your code in the debugger and it will stop when autorelease is called without a pool and that should resolve your problem.
In your example, yes, NSAutoreleasePool is carrying across methods since the invocation of `[self anotherMethod]` is nested inside -`(void)threadedMethod`.

* Q: NSAutoreleasePool carrying across methods?
* A: It depends:
	1. Across nested invocations, yes.
	2. Across sibling invocations, no.

And no matter what, the `NSAutoreleasePool` instance itself goes out of scope when the parent scope goes away. *-in your example, at the very end of `-(void)threadedMethod { }`*.

The article mentioned earlier (<http://thegothicparty.com/dev/macos/nsautoreleasepool/>) is quite clear about that.