NSThread and memory management
        Posted  
        
            by misfit153
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by misfit153
        
        
        
        Published on 2010-04-26T14:32:31Z
        Indexed on 
            2010/04/26
            14:43 UTC
        
        
        Read the original article
        Hit count: 274
        
Imagine I create and execute an NSThread object using detachNewThreadSelector:toTarget:withObject:. The method executed by the thread might look like this:
- (void)search {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    // perform a lengthy search here.
    [pool release];
}
I then might use the cancel method to kill the thread while it's running, before the pool gets released. What happens to the NSAutoreleasePool object? I suppose it will leak, won't it?
© Stack Overflow or respective owner