Re: [newbie] NSString code so it won't leak
Re: [newbie] NSString code so it won't leak
- Subject: Re: [newbie] NSString code so it won't leak
- From: Charles Srstka <email@hidden>
- Date: Tue, 10 Sep 2002 23:26:16 -0500
On Tuesday, September 10, 2002, at 10:44 PM, Dean Davis wrote:
Replaced the my first leaky example with the above
code. Not only does it not crash the application it
seems to stop the leak.
I posted my test project here...
http://www.afterten.com/Downloads/LeakTest.sit
For someone to verify or tell me what I'm doing wrong.
Cocoa is nice but fustrating that doesn't seem to be
any real authority on what needs to be released and
when. But I am reading all the links everyone has
posted on this thread.
What the hell?! I looked at the code, and it *should* crash. If it's
not (and if the other one was leaking), then the autorelease pool isn't
getting released, and that's really bizarre and should probably be
reported as a bug.
However, if you enclose your code in these two lines:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// your code here
[pool release];
it should fix the leak in the first example, and make the second
example crash.
Charles
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.