Skip navigation

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.

2 Comments

  1. Its me again. I’ve done by myself… and everything works fine. Thanks a lot for the hint! It has really saved my day!
    antonio

    • Hi Antonio, Glad that helped you. Sorry for not replying you earlier…. long time that I don’t check my blog. Will try to keep it more up-to-date.
      Best Regards,
      Daniel Froz


One Trackback/Pingback

  1. [...] Thanks Usr Inapto!  This was his solution. [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.