Re: Exceptions and autorelease pools

2011-12-09 Thread Uli Kusterer
On Dec 7, 2011, at 4:57 AM, Ken Thomases wrote: > On Dec 6, 2011, at 8:01 PM, Steve Sisak wrote: >> Given that operations have much shorter lifespan than threads, I'd worry >> about the leaked NSAutoreleasePool objects in a long-running application. > > When using Cocoa, exceptions should be, wel

Re: Exceptions and autorelease pools

2011-12-07 Thread Greg Parker
On Dec 6, 2011, at 6:01 PM, Steve Sisak wrote: > I realize that this is moot in the case of @autorelease, but in the context > of "best practices" for code that can't depend on ARC @autoreleasepool does not require ARC. -- Greg Parker gpar...@apple.com Runtime Wrangler __

Re: Exceptions and autorelease pools

2011-12-06 Thread Ken Thomases
On Dec 6, 2011, at 8:01 PM, Steve Sisak wrote: > Given that operations have much shorter lifespan than threads, I'd worry > about the leaked NSAutoreleasePool objects in a long-running application. When using Cocoa, exceptions should be, well, exceptional. They should not be used for flow cont

Re: Exceptions and autorelease pools

2011-12-06 Thread Steve Sisak
At 3:59 PM -0600 12/6/11, Ken Thomases wrote: The workaround is necessary because the exception object raised in allocAndRaise() has been autoreleased. It is no longer owned by anything and is only still around because the pool containing the pending release(s) has not been drained. When you

Re: Exceptions and autorelease pools

2011-12-06 Thread Larry Campbell
On Dec 6, 2011, at 4:59 PM, Ken Thomases wrote: > On Dec 6, 2011, at 2:47 PM, Larry Campbell wrote: > >> void allocAndRaise() >> { >> [[[NSString alloc] initWithString:@"foo bar and zot"] autorelease]; >> [NSException raise:@"foo" format:@"bar"]; >> } >> >> //#define LEAK >> >> void foo() >

Re: Exceptions and autorelease pools

2011-12-06 Thread Larry Campbell
On Dec 6, 2011, at 4:02 PM, Greg Parker wrote: > On Dec 6, 2011, at 12:47 PM, Larry Campbell wrote: >> (Mac OS X 10.6.8, Xcode 4.0.2, no GC) >> >> I believe the following paragraph in the "Using Autorelease Pools" section >> of the "Memory Management Programming Guide" is wrong, or misleading: >

Re: Exceptions and autorelease pools

2011-12-06 Thread Ken Thomases
On Dec 6, 2011, at 2:47 PM, Larry Campbell wrote: > void allocAndRaise() > { >[[[NSString alloc] initWithString:@"foo bar and zot"] autorelease]; >[NSException raise:@"foo" format:@"bar"]; > } > > //#define LEAK > > void foo() > { >NSAutoreleasePool *pool = [NSAutoreleasePool new]; >

Re: Exceptions and autorelease pools

2011-12-06 Thread Greg Parker
On Dec 6, 2011, at 12:47 PM, Larry Campbell wrote: > (Mac OS X 10.6.8, Xcode 4.0.2, no GC) > > I believe the following paragraph in the "Using Autorelease Pools" section of > the "Memory Management Programming Guide" is wrong, or misleading: > > "This behavior has implications for exceptional co

Exceptions and autorelease pools

2011-12-06 Thread Larry Campbell
(Mac OS X 10.6.8, Xcode 4.0.2, no GC) I believe the following paragraph in the "Using Autorelease Pools" section of the "Memory Management Programming Guide" is wrong, or misleading: "This behavior has implications for exceptional conditions. If an exception occurs, and the thread suddenly tran