How to properly increase ulimit -n on Lion?

Which command / configuration file controls the open file limits on OS X? Is there a different command for OS X 10.5 / 10.6 / 10.7? The options I explore below areulimitsysctl, and launchctl

"Too many open files" is apparently a common error on Leopard, perhaps other versions of OS X:

https://discussions.apple.com/thread/1449787?start=15&tstart=0

How to properly increase ulimit -n on Lion?

http://serverfault.com/questions/15564/where-are-the-default-ulimits-specified-on-os-x-10-5

There are many (related?) ways to view the open file limits:

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 2048
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 512
virtual memory          (kbytes, -v) unlimited


$ launchctl limit
cpu         unlimited      unlimited      
filesize    unlimited      unlimited      
data        unlimited      unlimited      
stack       8388608        67104768       
core        0              unlimited      
rss         unlimited      unlimited      
memlock     unlimited      unlimited      
maxproc     1024           2048           
maxfiles    2048           4096       

$ sysctl -a | grep files
kern.maxfiles = 32768
kern.maxfilesperproc = 16384
kern.maxfiles: 32768
kern.maxfilesperproc: 16384
kern.num_files: 2049

It has been claimed in some of the above posts that these can be modified with the following commands:

sudo launchctl limit maxfiles 16384 32768
sudo ulimit -n 32768
sudo sysctl -w kern.maxfilesperproc=16384
sudo sysctl -w kern.maxfiles=32768

However, out of the above commands, only the sysctl commands have any apparently effect (i.e. ulimit -n and launchctl limit show no change after the above commands have been entered, while sysctl -a does show the requested changes).

The corresponding locations to change these parameters for the OS are:

/etc/sysctl.conf
/etc/launchd.conf

(discovered one answer: ulimit only controls the current shellhttp://superuser.com/questions/302754/increase-the-maximum-number-of-open-file-descriptors-in-snow-leopard)


sudo launchctl limit maxfiles 16384 65536
sudo ulimit -n 65536
sudo sysctl -w kern.maxfilesperproc=65536
sudo sysctl -w kern.maxfiles=65536

65536
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值