• 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: NSTask Leaking...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask Leaking...


  • Subject: Re: NSTask Leaking...
  • From: Nick Zitzmann <email@hidden>
  • Date: Thu, 29 Jan 2009 11:32:46 -0700


On Jan 29, 2009, at 12:20 PM, Mr. Gecko wrote:

[theTask setArguments:[[NSArray arrayWithObjects:@"-s", MD5, nil] autorelease]];

This is incorrect and should be causing a crash, unless you're using GC. +arrayWithObjects: already returns an autoreleased object.


NSString *rMD5 = [[[[NSString alloc] initWithData:[[outPipe fileHandleForReading] readDataToEndOfFile] encoding: NSUTF8StringEncoding] componentsSeparatedByString:@" = "] objectAtIndex:1];

Your memory leak is right here. The result of -initWithData: needs to be autoreleased. But I'd also recommend breaking up that line to be easier to read...


	rMD5 = [self replace:@"\n" with:@"" source:rMD5];

	return [rMD5 autorelease];


If your replace method isn't returning an autoreleased object, it should be. Don't break with conventions.

Also, if you want to hash something, then you should probably use the functions in libcrypto instead of using NSTask. That'll at least be faster...

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



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSTask Leaking... (From: "Mr. Gecko" <email@hidden>)

  • Prev by Date: Re: NSTask Leaking...
  • Next by Date: Re: NSTask Leaking...
  • Previous by thread: Re: NSTask Leaking...
  • Next by thread: Re: NSTask Leaking...
  • Index(es):
    • Date
    • Thread