• 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: Crash after weeks of doing nothing to my code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash after weeks of doing nothing to my code


  • Subject: Re: Crash after weeks of doing nothing to my code
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 2 Aug 2005 20:24:50 -0600


On Aug 2, 2005, at 7:36 PM, Adam wrote:

Anyone have a clue?

Yes. Take a look at that for loop:

NSString *oneStringFromArray = [[NSString alloc] init];

Here you create a completely empty, immutable object. This isn't necessary because you can't do much of anything with it. If for some reason you want to make empty strings, then you should probably use @"" instead.


oneStringFromArray = [arrayToStripNewLineCharFromString objectAtIndex:i];

Here the program leaks memory, because you blew away the pointer to the string you created one line before.


cookieString = [[NSString alloc] initWithFormat:@"(%d)", cookie];

This isn't part of the problem, but here you're creating a string and not releasing it, so it's another memory leak.


oneStringFromArray = [cookieString stringByAppendingString:oneStringFromArray];

Here you overwrite the pointer again.

[oneStringFromArray release];

Here you double-release the object that was returned by - stringByAppendingString: above. Since -stringByAppendingString: returns an autoreleased object, this is the most likely cause of the crash.


Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Crash after weeks of doing nothing to my code
      • From: Greg Hurrell <email@hidden>
    • Re: Crash after weeks of doing nothing to my code
      • From: Adam <email@hidden>
References: 
 >Crash after weeks of doing nothing to my code (From: Adam <email@hidden>)

  • Prev by Date: Re: Fullscreen window after hiding Dock works in 10.4 but not 10.3
  • Next by Date: Re: Crash after weeks of doing nothing to my code
  • Previous by thread: Crash after weeks of doing nothing to my code
  • Next by thread: Re: Crash after weeks of doing nothing to my code
  • Index(es):
    • Date
    • Thread