Friday, August 21, 2009

"resource temporarily unavailable" on the Mac

So if you are a power user you might hit resource limits on the Mac just like the old UNIX times.

So today I was unable to create new process on my Mac:
sh-3.2$ sh
sh-3.2$ sh
sh: fork: Resource temporarily unavailable
sh-3.2$ exit
sh-3.2$ ps ux|wc
sh: fork: Resource temporarily unavailable


So I killed a few process and ran ps and pipe it to wc:

sh-3.2$ exit
sh-3.2$ exit
sh-3.2$ ps ux|wc -l
266

266 processes isn't a huge number in today's standards right?

Guess Apple has a different view - 266 is a pre-defined limit of the maximum number of processes a single user (uid) can create on the Mac:

sh-3.2$ sudo sysctl -a |grep maxprocperuid
kern.exec: unknown type returned
kern.maxprocperuid = 266
kern.maxprocperuid: 266


Solution? Simple pump it up by:
$ sudo sysctl -w kern.maxprocperuid = 512