This will be a quick post. Working with a stress test tool, I realized that most of the tests were failing due to the “too many files open” error from the Mac OS X. Immediately figure out that Mac OS X comes with the 256 as the default limit for the number of the files open by a single process. This would be ok for most of the users but what about developers which usually works with a test environment on their own machine?
Launchd is the daemon responsible for managing process. It also controls some of the processes limit information (soft and hard limits for open files, max number of child processes, so on…). The solution is to make use of the launchctl tool from the command line and create the launchd.conf file for the persistent change. Open your Terminal and type the following commands:
sudo echo “limit maxfiles 1000000 1000000″ > /etc/launchd.conf
launchctl limit maxfiles 1000000 1000000
Note for Programmers:
Programs utilizing I/O multiplex or non-blocking I/O on Mac OS X are by default restricted to 1024 file descriptors per process. In order to overcome this limitation you can either re-define FD_SETSIZE macro (before you include <sys/types.h> or to limit the maxfiles to 1024. This will make the warning messages disappear during the compilation time.