Why is `/etc/sysctl.conf` not determining the `kern.maxfiles` setting

kernelsettings

I've been having a persistent "too many open files in system" error on my machine (OSX 10.7.5).

When I run sysctl kern.maxfiles and sysctl kern.maxfilesperproc, both output 2048.

This article says those settings default to 12,288 and 10,240, respectively. It says you can permanently change the settings by editing /etc/sysctl.conf.

I've done that. The contents of that file are now:

kern.maxfiles=12288
kern.maxfilesperproc=10240

The permissions on it are -rw-r--r--, and it belongs to root in the wheel group.

This file has no effect on what my system is doing. After restart, if I check the maxfile settings, they are unchanged.

Is there something else controlling these settings, making my defaults lower than what they should be and overriding my explicit settings?

How can I fix these settings?


Update

I've since tried, to no avail:

Lower Limits

Setting them to 4000 and 3500 in case the system ignores settings over a certain threshold.

Using /etc/rc.common

I put the following, not in /etc/sysctl.conf, but in /ect/rc.common:

sysctl -w kern.maxfiles=4000
sysctl -w kern.maxfilesperproc=3500

Using my shell's configuration file

I put the same commands as above in my .zshrc, but they don't work without sudo.

Best Answer

See /etc/launchd.conf

For some reason, I had this in /etc/launchd.conf:

limit maxfiles 2048

This apparently overrode my settings in /etc/sysctl.conf, either by being considered more important or by being executed later in the bootup process.

After I removed this and rebooted, my settings from /etc/sysctl.conf had taken effect.