• 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: 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.

  • Follow-Ups:
    • Re: [newbie] NSString code so it won't leak
      • From: Chris Ross <email@hidden>
References: 
 >Re: [newbie] NSString code so it won't leak (From: Dean Davis <email@hidden>)

  • Prev by Date: Validating NSControl
  • Next by Date: Re: Cocoa Audio question
  • 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