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: James DiPalma <email@hidden>
- Date: Wed, 11 Sep 2002 14:57:50 -0400
>
I have an example program that leaks. Has anyone even
>
botherd to look at it?
I looked at your code and I have a few comments
- pushButton: will leak a MyFee object every time pressed *
- URLHandleResourceDidFinishLoading: should not release filedata
- URLHandleResourceDidFinishLoading: should not release sender
- When MinuteTimer fires a second time, your app crashes
- leaks (a command line tool) reports 0 leaks (app doesn't crash
after fixing extra releases)
I used ObjectAlloc to see what residual NSStrings your code leaves
around after your 1st firing:
I see 3 or 4 CFString (CFSTR)
"DiskArbMode" from InitializeDiskArbitrationMessages
"/usr/share/zoneinfo/" from NSLog
";?/" from NSLog
"d-d-d d:d:.3f %s[%d] %s " from NSLog
I see 4 CFString (immutable)
"US/Eastern" from NSLog
"EDT" from NSLog
"EST" from NSLog
"EWT" from NSLog
All of these strings seem to go away if you wait a little bit (maybe
NSLog caches strings for this "2002-09-11 14:00:46.249 LeakTest[5309]").
Not one of these strings is from your code.
-jim
* you have no dealloc method which could release one instance, but
multiple button presses would still leak. Not a big deal since this code
is clearly designed as a test, but simple init and dealloc methods are
good practice.
_______________________________________________
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.