On Jun 11, 2005, at 8:30 AM, Theodore H. Smith wrote:
OK, well hows about this. If I use NSAutoReleasePool well enough, maybe I can pin this bug down?
I've never done this before, though, it just seems like it might be possible, from what I read. I'm not exactly sure yet on what additional bugs I might create by (badly) using NSAutoReleasePool.
Let's say I had this code:
NSAutoReleasePool* p = [[NSAutoReleasePool alloc]init];
NSString* s = [NSString stringWithCString : "hello"];
[p drain];
[self doStuffWith : s]; // crash.
[p release]; // we never get here
Something like that would a bug introduced by badly using NSAutoReleasePool, right?
Then the problem becomes finding out which references to NSObjects I have for which lifetimes.
Let's (very theoretically) say then that I am able to perfectly figure out the lifetime of every NSObject I have.
NSAutoReleasePool* p = [[NSAutoReleasePool alloc]init];
NSString* s = [NSString stringWithCString : "hello"];
[s autorelease]; // over released!
[self doStuffWith : s];
[p drain]; // crash.
[p release];
Would that then help me pin down my bug, by making the crash closer to the point where I overrelease?