• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [newbie] NSString code so it won't leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: [newbie] NSString code so it won't leak
      • From: Dean Davis <email@hidden>
  • Prev by Date: [newbie] Getting mouseMoved events.
  • Next by Date: Localizers
  • Previous by thread: Re: [newbie] NSString code so it won't leak
  • Next by thread: Re: [newbie] NSString code so it won't leak
  • Index(es):
    • Date
    • Thread