Re: [NSPipe pipe] returning nil (running out of filehandles?)
Re: [NSPipe pipe] returning nil (running out of filehandles?)
- Subject: Re: [NSPipe pipe] returning nil (running out of filehandles?)
- From: Jens Alfke <email@hidden>
- Date: Tue, 1 Apr 2008 22:45:32 -0700
On 1 Apr '08, at 4:53 PM, Martin Redington wrote:
You'd kind of hope that NSTask would clean up in its dealloc method,
but apparently not.
But you're not (and shouldn't be) calling -dealloc, you're calling -
release. My guess is that the NSTask retains itself while the process
is running, so as not to leave anything dangling, then releases itself
when it exits. If you don't wait for the task to exit, but start lots
of others as fast as you can, you're probably piling up lots of tasks
at once. Collect about 84, and suddenly you can't start any more.
Jim - any particular reason why you'd not use NSTask?
I guess I'm paying the fork/exec overhead, and some interprocess
piping and (a very small bit of) extra I/O for each NSTask.
It's vastly slower to do this by forking a process.
NSTask can be annoying to deal with (I've had trouble getting it to
cooperate, and you're running into problems too.)
It's more code than simply calling CommonDigest, and it's less clear
to the reader what's going on.
I will actually be caching a lot of the output, so I expect the
numbers to be much smaller on subsequent scans, although even once
off, 3,000 spawns does seem a bit gratuitous. Performance was much
better than I expected though - about 12 minutes for the md5 phase.
That's 0.25 seconds per file. I think you can do better than that,
unless the files are really big.
Also, you're aware that MD5 shouldn't be used for anything security-
related anymore? Last I heard it's pretty close to being fully broken.
SHA-1 is a lot more secure, and has a larger output which itself makes
collisions less likely.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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