Increase the maximum number of open file descriptors in Snow Leopard?
I am trying to do something that requires a large number of file descriptors
sudo ulimit -n 12288
is as high as Snow Leopard wants to go; beyond this results in
/usr/bin/ulimit: line 4: ulimit: open files: cannot modify limit: Invalid argument.
I want to raise the number much higher, say 100000. Is it possible?
mac osx-snow-leopard ulimit file-descriptors
add a comment |
I am trying to do something that requires a large number of file descriptors
sudo ulimit -n 12288
is as high as Snow Leopard wants to go; beyond this results in
/usr/bin/ulimit: line 4: ulimit: open files: cannot modify limit: Invalid argument.
I want to raise the number much higher, say 100000. Is it possible?
mac osx-snow-leopard ulimit file-descriptors
4
This question's answers no longer work in OSX Mavericks.
– Howard
Jan 7 '14 at 10:02
2
Runningecho limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and restarting works for me in Mavericks.
– user495470
May 30 '14 at 17:40
add a comment |
I am trying to do something that requires a large number of file descriptors
sudo ulimit -n 12288
is as high as Snow Leopard wants to go; beyond this results in
/usr/bin/ulimit: line 4: ulimit: open files: cannot modify limit: Invalid argument.
I want to raise the number much higher, say 100000. Is it possible?
mac osx-snow-leopard ulimit file-descriptors
I am trying to do something that requires a large number of file descriptors
sudo ulimit -n 12288
is as high as Snow Leopard wants to go; beyond this results in
/usr/bin/ulimit: line 4: ulimit: open files: cannot modify limit: Invalid argument.
I want to raise the number much higher, say 100000. Is it possible?
mac osx-snow-leopard ulimit file-descriptors
mac osx-snow-leopard ulimit file-descriptors
asked Jun 27 '11 at 10:56
Chris PooleChris Poole
1,15911013
1,15911013
4
This question's answers no longer work in OSX Mavericks.
– Howard
Jan 7 '14 at 10:02
2
Runningecho limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and restarting works for me in Mavericks.
– user495470
May 30 '14 at 17:40
add a comment |
4
This question's answers no longer work in OSX Mavericks.
– Howard
Jan 7 '14 at 10:02
2
Runningecho limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and restarting works for me in Mavericks.
– user495470
May 30 '14 at 17:40
4
4
This question's answers no longer work in OSX Mavericks.
– Howard
Jan 7 '14 at 10:02
This question's answers no longer work in OSX Mavericks.
– Howard
Jan 7 '14 at 10:02
2
2
Running
echo limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and restarting works for me in Mavericks.– user495470
May 30 '14 at 17:40
Running
echo limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and restarting works for me in Mavericks.– user495470
May 30 '14 at 17:40
add a comment |
7 Answers
7
active
oldest
votes
Using ulimit
command only changes the resource limits for the current shell and its children and sudo ulimit
creates a root shell, adjusts its limits, and then exits (thus having, as far as I can see, no real effect).
To exceed 12288, you need to adjust the kernel's kern.maxfiles
and kern.maxfilesperproc
parameters, and also (at least according to this blog entry, which is a summary of this discussion) a launchd limit. You can use launchctl limit
to adjust all of these at once:
sudo launchctl limit maxfiles 1000000 1000000
To make this permanent (i.e not reset when you reboot), create /etc/launchd.conf
containing:
limit maxfiles 1000000 1000000
Then you can use ulimit
(but without the sudo
) to adjust your process limit.
If this doesn't do it, you may be running into size limits in the kernel. If your model supports it, booting the kernel in 64-bit mode may help.
sudo launchctl limit maxfiles 1000000 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
– Thomas Hunter
May 14 '14 at 0:16
2
Be careful when adding that line tolaunchd.conf
. I think if the number is too small, it can make your computer unusable. For example, I usedlimit maxfiles 1024 1024
and I had a really hard time changing it back.
– Shawn
Oct 12 '14 at 12:25
1
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
It does not work, my fd number can not exceed 6k even if I set ulimit -Sn 10240 successfully.
– Jian Weihang
Nov 5 '15 at 18:47
@JianWeihang fd numbers are per-process so I assume other processes happened to have 4000 files open. Do you happen to run Chrome? ;)
– Trejkaz
Jul 26 '17 at 23:06
add a comment |
The following should resolve most solutions (and are listed in order of their hierarchy):
echo 'kern.maxfiles=20480' | sudo tee -a /etc/sysctl.conf
echo -e 'limit maxfiles 8192 20480nlimit maxproc 1000 2000' | sudo tee -a /etc/launchd.conf
echo 'ulimit -n 4096' | sudo tee -a /etc/profile
Notes:
- You will need to restart for these changes to take effect.
- AFAIK you can no longer set limits to 'unlimited' under OS X
- launchctl maxfiles are bounded by sysctl maxfiles, and
therefore cannot exceed them - sysctl seems to inherit kern.maxfilesperproc from launchctl
maxfiles - ulimit seems to inherit it's 'open files' value from
launchctl by default - you can set a custom ulimit within /etc/profile, or
~/.profile ; while this isn't required I've provided an example - Be cautious when setting any of these values to a very high number when compared with their default - the features exist stability/security. I've taken these example numbers that I believe to be reasonable, written on other websites.
2
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
add a comment |
It seems like there is an entirely different method for changing the open files limit for each version of OS X!
For OS X Sierra (10.12.X) you need to:
1.
In Library/LaunchDaemons
create a file named limit.maxfiles.plist
and paste the following in (feel free to change the two numbers (which are the soft and hard limits, respectively):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>64000</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
2.
Change the owner of your new file:
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
3.
Load these new settings:
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
4.
Finally, check that the limits are correct:
launchctl limit maxfiles
2
This answer is great, and I found some background to add to it here, @ninjaPixel: blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan
– Dean Radcliffe
Feb 6 '17 at 18:29
add a comment |
It seems that OS X Lion will not permit "unlimited" as a value:
% sudo launchctl limit maxfiles 8192 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
Providing numerical values for both the soft and the hard limit does the job:
% sudo launchctl limit maxfiles 4096 8192
3
If one of the values was unlimited, using-1
as value results in12288
. It's possible to use larger numeric values, e.g.sudo launchctl limit maxfiles 15000 150000
. I'm not sure these settings have an effect then, though.
– Daniel Beck♦
Dec 10 '11 at 10:59
add a comment |
On Mavericks its simple. As a regular user:
ulimit -n 8192
You can check the updated settings via
ulimit -a
On my machine:
ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-v: address space (kbytes) unlimited
-l: locked-in-memory size (kbytes) unlimited
-u: processes 709
-n: file descriptors 8192
2
Consider revising your solution. You're setting a ulimit of 1024, then showing the output file descriptors as 8192 (should be 1024). You're approach is also probelmatic without sudo, try changing it a few times for yourself.
– y3sh
Oct 15 '14 at 13:34
1
sudo should not be used here but this answer is incorrect. Mavericks users should useecho limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and then restart their machine
– Kyle Chadha
Mar 17 '15 at 22:12
add a comment |
On OS X 10.13.6 this works for me:
$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 10240
$ sudo sysctl -w kern.maxfiles=1048600
kern.maxfiles: 12288 -> 1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
kern.maxfilesperproc: 10240 -> 1048576
$ ulimit -S -n
256
$ ulimit -S -n 1048576
$ ulimit -S -n
1048576
add a comment |
Some limits cannot be changed by ulimit
, because they only apply to the current shell, therefore launchctl
command should be used to change the limits globally, e.g.
sudo launchctl limit maxfiles 100000 unlimited
Please note that applying these limits in /etc/launchd.conf
(as suggested in other answers) is no longer supported in the recent macOS releases. Although can still use launchd.plist
(see: man launchd.plist
) such as per-user or system-wide plist
configuration files as suggested here and there.
To make these limits persistent, you can use /etc/sysctl.conf
file and add for example:
kern.maxprocperuid=1000
kern.maxproc=2000
kern.maxfilesperproc=20000
kern.maxfiles=50000
For changes to take the effect, it requires reboot.
To see the current limits, run: launchctl limit
or sysctl -a | grep ^kern.max
.
See also: How to persist ulimit settings in macOS?
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f302754%2fincrease-the-maximum-number-of-open-file-descriptors-in-snow-leopard%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using ulimit
command only changes the resource limits for the current shell and its children and sudo ulimit
creates a root shell, adjusts its limits, and then exits (thus having, as far as I can see, no real effect).
To exceed 12288, you need to adjust the kernel's kern.maxfiles
and kern.maxfilesperproc
parameters, and also (at least according to this blog entry, which is a summary of this discussion) a launchd limit. You can use launchctl limit
to adjust all of these at once:
sudo launchctl limit maxfiles 1000000 1000000
To make this permanent (i.e not reset when you reboot), create /etc/launchd.conf
containing:
limit maxfiles 1000000 1000000
Then you can use ulimit
(but without the sudo
) to adjust your process limit.
If this doesn't do it, you may be running into size limits in the kernel. If your model supports it, booting the kernel in 64-bit mode may help.
sudo launchctl limit maxfiles 1000000 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
– Thomas Hunter
May 14 '14 at 0:16
2
Be careful when adding that line tolaunchd.conf
. I think if the number is too small, it can make your computer unusable. For example, I usedlimit maxfiles 1024 1024
and I had a really hard time changing it back.
– Shawn
Oct 12 '14 at 12:25
1
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
It does not work, my fd number can not exceed 6k even if I set ulimit -Sn 10240 successfully.
– Jian Weihang
Nov 5 '15 at 18:47
@JianWeihang fd numbers are per-process so I assume other processes happened to have 4000 files open. Do you happen to run Chrome? ;)
– Trejkaz
Jul 26 '17 at 23:06
add a comment |
Using ulimit
command only changes the resource limits for the current shell and its children and sudo ulimit
creates a root shell, adjusts its limits, and then exits (thus having, as far as I can see, no real effect).
To exceed 12288, you need to adjust the kernel's kern.maxfiles
and kern.maxfilesperproc
parameters, and also (at least according to this blog entry, which is a summary of this discussion) a launchd limit. You can use launchctl limit
to adjust all of these at once:
sudo launchctl limit maxfiles 1000000 1000000
To make this permanent (i.e not reset when you reboot), create /etc/launchd.conf
containing:
limit maxfiles 1000000 1000000
Then you can use ulimit
(but without the sudo
) to adjust your process limit.
If this doesn't do it, you may be running into size limits in the kernel. If your model supports it, booting the kernel in 64-bit mode may help.
sudo launchctl limit maxfiles 1000000 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
– Thomas Hunter
May 14 '14 at 0:16
2
Be careful when adding that line tolaunchd.conf
. I think if the number is too small, it can make your computer unusable. For example, I usedlimit maxfiles 1024 1024
and I had a really hard time changing it back.
– Shawn
Oct 12 '14 at 12:25
1
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
It does not work, my fd number can not exceed 6k even if I set ulimit -Sn 10240 successfully.
– Jian Weihang
Nov 5 '15 at 18:47
@JianWeihang fd numbers are per-process so I assume other processes happened to have 4000 files open. Do you happen to run Chrome? ;)
– Trejkaz
Jul 26 '17 at 23:06
add a comment |
Using ulimit
command only changes the resource limits for the current shell and its children and sudo ulimit
creates a root shell, adjusts its limits, and then exits (thus having, as far as I can see, no real effect).
To exceed 12288, you need to adjust the kernel's kern.maxfiles
and kern.maxfilesperproc
parameters, and also (at least according to this blog entry, which is a summary of this discussion) a launchd limit. You can use launchctl limit
to adjust all of these at once:
sudo launchctl limit maxfiles 1000000 1000000
To make this permanent (i.e not reset when you reboot), create /etc/launchd.conf
containing:
limit maxfiles 1000000 1000000
Then you can use ulimit
(but without the sudo
) to adjust your process limit.
If this doesn't do it, you may be running into size limits in the kernel. If your model supports it, booting the kernel in 64-bit mode may help.
Using ulimit
command only changes the resource limits for the current shell and its children and sudo ulimit
creates a root shell, adjusts its limits, and then exits (thus having, as far as I can see, no real effect).
To exceed 12288, you need to adjust the kernel's kern.maxfiles
and kern.maxfilesperproc
parameters, and also (at least according to this blog entry, which is a summary of this discussion) a launchd limit. You can use launchctl limit
to adjust all of these at once:
sudo launchctl limit maxfiles 1000000 1000000
To make this permanent (i.e not reset when you reboot), create /etc/launchd.conf
containing:
limit maxfiles 1000000 1000000
Then you can use ulimit
(but without the sudo
) to adjust your process limit.
If this doesn't do it, you may be running into size limits in the kernel. If your model supports it, booting the kernel in 64-bit mode may help.
edited Jul 29 '17 at 12:58
kenorb
10.9k1578112
10.9k1578112
answered Jun 27 '11 at 21:17
Gordon DavissonGordon Davisson
25.6k44350
25.6k44350
sudo launchctl limit maxfiles 1000000 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
– Thomas Hunter
May 14 '14 at 0:16
2
Be careful when adding that line tolaunchd.conf
. I think if the number is too small, it can make your computer unusable. For example, I usedlimit maxfiles 1024 1024
and I had a really hard time changing it back.
– Shawn
Oct 12 '14 at 12:25
1
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
It does not work, my fd number can not exceed 6k even if I set ulimit -Sn 10240 successfully.
– Jian Weihang
Nov 5 '15 at 18:47
@JianWeihang fd numbers are per-process so I assume other processes happened to have 4000 files open. Do you happen to run Chrome? ;)
– Trejkaz
Jul 26 '17 at 23:06
add a comment |
sudo launchctl limit maxfiles 1000000 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
– Thomas Hunter
May 14 '14 at 0:16
2
Be careful when adding that line tolaunchd.conf
. I think if the number is too small, it can make your computer unusable. For example, I usedlimit maxfiles 1024 1024
and I had a really hard time changing it back.
– Shawn
Oct 12 '14 at 12:25
1
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
It does not work, my fd number can not exceed 6k even if I set ulimit -Sn 10240 successfully.
– Jian Weihang
Nov 5 '15 at 18:47
@JianWeihang fd numbers are per-process so I assume other processes happened to have 4000 files open. Do you happen to run Chrome? ;)
– Trejkaz
Jul 26 '17 at 23:06
sudo launchctl limit maxfiles 1000000 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.– Thomas Hunter
May 14 '14 at 0:16
sudo launchctl limit maxfiles 1000000 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.– Thomas Hunter
May 14 '14 at 0:16
2
2
Be careful when adding that line to
launchd.conf
. I think if the number is too small, it can make your computer unusable. For example, I used limit maxfiles 1024 1024
and I had a really hard time changing it back.– Shawn
Oct 12 '14 at 12:25
Be careful when adding that line to
launchd.conf
. I think if the number is too small, it can make your computer unusable. For example, I used limit maxfiles 1024 1024
and I had a really hard time changing it back.– Shawn
Oct 12 '14 at 12:25
1
1
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
It does not work, my fd number can not exceed 6k even if I set ulimit -Sn 10240 successfully.
– Jian Weihang
Nov 5 '15 at 18:47
It does not work, my fd number can not exceed 6k even if I set ulimit -Sn 10240 successfully.
– Jian Weihang
Nov 5 '15 at 18:47
@JianWeihang fd numbers are per-process so I assume other processes happened to have 4000 files open. Do you happen to run Chrome? ;)
– Trejkaz
Jul 26 '17 at 23:06
@JianWeihang fd numbers are per-process so I assume other processes happened to have 4000 files open. Do you happen to run Chrome? ;)
– Trejkaz
Jul 26 '17 at 23:06
add a comment |
The following should resolve most solutions (and are listed in order of their hierarchy):
echo 'kern.maxfiles=20480' | sudo tee -a /etc/sysctl.conf
echo -e 'limit maxfiles 8192 20480nlimit maxproc 1000 2000' | sudo tee -a /etc/launchd.conf
echo 'ulimit -n 4096' | sudo tee -a /etc/profile
Notes:
- You will need to restart for these changes to take effect.
- AFAIK you can no longer set limits to 'unlimited' under OS X
- launchctl maxfiles are bounded by sysctl maxfiles, and
therefore cannot exceed them - sysctl seems to inherit kern.maxfilesperproc from launchctl
maxfiles - ulimit seems to inherit it's 'open files' value from
launchctl by default - you can set a custom ulimit within /etc/profile, or
~/.profile ; while this isn't required I've provided an example - Be cautious when setting any of these values to a very high number when compared with their default - the features exist stability/security. I've taken these example numbers that I believe to be reasonable, written on other websites.
2
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
add a comment |
The following should resolve most solutions (and are listed in order of their hierarchy):
echo 'kern.maxfiles=20480' | sudo tee -a /etc/sysctl.conf
echo -e 'limit maxfiles 8192 20480nlimit maxproc 1000 2000' | sudo tee -a /etc/launchd.conf
echo 'ulimit -n 4096' | sudo tee -a /etc/profile
Notes:
- You will need to restart for these changes to take effect.
- AFAIK you can no longer set limits to 'unlimited' under OS X
- launchctl maxfiles are bounded by sysctl maxfiles, and
therefore cannot exceed them - sysctl seems to inherit kern.maxfilesperproc from launchctl
maxfiles - ulimit seems to inherit it's 'open files' value from
launchctl by default - you can set a custom ulimit within /etc/profile, or
~/.profile ; while this isn't required I've provided an example - Be cautious when setting any of these values to a very high number when compared with their default - the features exist stability/security. I've taken these example numbers that I believe to be reasonable, written on other websites.
2
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
add a comment |
The following should resolve most solutions (and are listed in order of their hierarchy):
echo 'kern.maxfiles=20480' | sudo tee -a /etc/sysctl.conf
echo -e 'limit maxfiles 8192 20480nlimit maxproc 1000 2000' | sudo tee -a /etc/launchd.conf
echo 'ulimit -n 4096' | sudo tee -a /etc/profile
Notes:
- You will need to restart for these changes to take effect.
- AFAIK you can no longer set limits to 'unlimited' under OS X
- launchctl maxfiles are bounded by sysctl maxfiles, and
therefore cannot exceed them - sysctl seems to inherit kern.maxfilesperproc from launchctl
maxfiles - ulimit seems to inherit it's 'open files' value from
launchctl by default - you can set a custom ulimit within /etc/profile, or
~/.profile ; while this isn't required I've provided an example - Be cautious when setting any of these values to a very high number when compared with their default - the features exist stability/security. I've taken these example numbers that I believe to be reasonable, written on other websites.
The following should resolve most solutions (and are listed in order of their hierarchy):
echo 'kern.maxfiles=20480' | sudo tee -a /etc/sysctl.conf
echo -e 'limit maxfiles 8192 20480nlimit maxproc 1000 2000' | sudo tee -a /etc/launchd.conf
echo 'ulimit -n 4096' | sudo tee -a /etc/profile
Notes:
- You will need to restart for these changes to take effect.
- AFAIK you can no longer set limits to 'unlimited' under OS X
- launchctl maxfiles are bounded by sysctl maxfiles, and
therefore cannot exceed them - sysctl seems to inherit kern.maxfilesperproc from launchctl
maxfiles - ulimit seems to inherit it's 'open files' value from
launchctl by default - you can set a custom ulimit within /etc/profile, or
~/.profile ; while this isn't required I've provided an example - Be cautious when setting any of these values to a very high number when compared with their default - the features exist stability/security. I've taken these example numbers that I believe to be reasonable, written on other websites.
answered Dec 3 '12 at 12:07
errant.infoerrant.info
51143
51143
2
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
add a comment |
2
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
2
2
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
– Alice Purcell
Sep 25 '15 at 10:38
add a comment |
It seems like there is an entirely different method for changing the open files limit for each version of OS X!
For OS X Sierra (10.12.X) you need to:
1.
In Library/LaunchDaemons
create a file named limit.maxfiles.plist
and paste the following in (feel free to change the two numbers (which are the soft and hard limits, respectively):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>64000</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
2.
Change the owner of your new file:
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
3.
Load these new settings:
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
4.
Finally, check that the limits are correct:
launchctl limit maxfiles
2
This answer is great, and I found some background to add to it here, @ninjaPixel: blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan
– Dean Radcliffe
Feb 6 '17 at 18:29
add a comment |
It seems like there is an entirely different method for changing the open files limit for each version of OS X!
For OS X Sierra (10.12.X) you need to:
1.
In Library/LaunchDaemons
create a file named limit.maxfiles.plist
and paste the following in (feel free to change the two numbers (which are the soft and hard limits, respectively):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>64000</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
2.
Change the owner of your new file:
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
3.
Load these new settings:
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
4.
Finally, check that the limits are correct:
launchctl limit maxfiles
2
This answer is great, and I found some background to add to it here, @ninjaPixel: blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan
– Dean Radcliffe
Feb 6 '17 at 18:29
add a comment |
It seems like there is an entirely different method for changing the open files limit for each version of OS X!
For OS X Sierra (10.12.X) you need to:
1.
In Library/LaunchDaemons
create a file named limit.maxfiles.plist
and paste the following in (feel free to change the two numbers (which are the soft and hard limits, respectively):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>64000</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
2.
Change the owner of your new file:
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
3.
Load these new settings:
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
4.
Finally, check that the limits are correct:
launchctl limit maxfiles
It seems like there is an entirely different method for changing the open files limit for each version of OS X!
For OS X Sierra (10.12.X) you need to:
1.
In Library/LaunchDaemons
create a file named limit.maxfiles.plist
and paste the following in (feel free to change the two numbers (which are the soft and hard limits, respectively):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>64000</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
2.
Change the owner of your new file:
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
3.
Load these new settings:
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
4.
Finally, check that the limits are correct:
launchctl limit maxfiles
answered Jan 24 '17 at 14:50
ninjaPixelninjaPixel
1,181108
1,181108
2
This answer is great, and I found some background to add to it here, @ninjaPixel: blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan
– Dean Radcliffe
Feb 6 '17 at 18:29
add a comment |
2
This answer is great, and I found some background to add to it here, @ninjaPixel: blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan
– Dean Radcliffe
Feb 6 '17 at 18:29
2
2
This answer is great, and I found some background to add to it here, @ninjaPixel: blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan
– Dean Radcliffe
Feb 6 '17 at 18:29
This answer is great, and I found some background to add to it here, @ninjaPixel: blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan
– Dean Radcliffe
Feb 6 '17 at 18:29
add a comment |
It seems that OS X Lion will not permit "unlimited" as a value:
% sudo launchctl limit maxfiles 8192 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
Providing numerical values for both the soft and the hard limit does the job:
% sudo launchctl limit maxfiles 4096 8192
3
If one of the values was unlimited, using-1
as value results in12288
. It's possible to use larger numeric values, e.g.sudo launchctl limit maxfiles 15000 150000
. I'm not sure these settings have an effect then, though.
– Daniel Beck♦
Dec 10 '11 at 10:59
add a comment |
It seems that OS X Lion will not permit "unlimited" as a value:
% sudo launchctl limit maxfiles 8192 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
Providing numerical values for both the soft and the hard limit does the job:
% sudo launchctl limit maxfiles 4096 8192
3
If one of the values was unlimited, using-1
as value results in12288
. It's possible to use larger numeric values, e.g.sudo launchctl limit maxfiles 15000 150000
. I'm not sure these settings have an effect then, though.
– Daniel Beck♦
Dec 10 '11 at 10:59
add a comment |
It seems that OS X Lion will not permit "unlimited" as a value:
% sudo launchctl limit maxfiles 8192 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
Providing numerical values for both the soft and the hard limit does the job:
% sudo launchctl limit maxfiles 4096 8192
It seems that OS X Lion will not permit "unlimited" as a value:
% sudo launchctl limit maxfiles 8192 unlimited
Neither the hard nor soft limit for "maxfiles" can be unlimited. Please use a numeric parameter for both.
Providing numerical values for both the soft and the hard limit does the job:
% sudo launchctl limit maxfiles 4096 8192
answered Dec 10 '11 at 10:11
crishojcrishoj
33123
33123
3
If one of the values was unlimited, using-1
as value results in12288
. It's possible to use larger numeric values, e.g.sudo launchctl limit maxfiles 15000 150000
. I'm not sure these settings have an effect then, though.
– Daniel Beck♦
Dec 10 '11 at 10:59
add a comment |
3
If one of the values was unlimited, using-1
as value results in12288
. It's possible to use larger numeric values, e.g.sudo launchctl limit maxfiles 15000 150000
. I'm not sure these settings have an effect then, though.
– Daniel Beck♦
Dec 10 '11 at 10:59
3
3
If one of the values was unlimited, using
-1
as value results in 12288
. It's possible to use larger numeric values, e.g. sudo launchctl limit maxfiles 15000 150000
. I'm not sure these settings have an effect then, though.– Daniel Beck♦
Dec 10 '11 at 10:59
If one of the values was unlimited, using
-1
as value results in 12288
. It's possible to use larger numeric values, e.g. sudo launchctl limit maxfiles 15000 150000
. I'm not sure these settings have an effect then, though.– Daniel Beck♦
Dec 10 '11 at 10:59
add a comment |
On Mavericks its simple. As a regular user:
ulimit -n 8192
You can check the updated settings via
ulimit -a
On my machine:
ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-v: address space (kbytes) unlimited
-l: locked-in-memory size (kbytes) unlimited
-u: processes 709
-n: file descriptors 8192
2
Consider revising your solution. You're setting a ulimit of 1024, then showing the output file descriptors as 8192 (should be 1024). You're approach is also probelmatic without sudo, try changing it a few times for yourself.
– y3sh
Oct 15 '14 at 13:34
1
sudo should not be used here but this answer is incorrect. Mavericks users should useecho limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and then restart their machine
– Kyle Chadha
Mar 17 '15 at 22:12
add a comment |
On Mavericks its simple. As a regular user:
ulimit -n 8192
You can check the updated settings via
ulimit -a
On my machine:
ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-v: address space (kbytes) unlimited
-l: locked-in-memory size (kbytes) unlimited
-u: processes 709
-n: file descriptors 8192
2
Consider revising your solution. You're setting a ulimit of 1024, then showing the output file descriptors as 8192 (should be 1024). You're approach is also probelmatic without sudo, try changing it a few times for yourself.
– y3sh
Oct 15 '14 at 13:34
1
sudo should not be used here but this answer is incorrect. Mavericks users should useecho limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and then restart their machine
– Kyle Chadha
Mar 17 '15 at 22:12
add a comment |
On Mavericks its simple. As a regular user:
ulimit -n 8192
You can check the updated settings via
ulimit -a
On my machine:
ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-v: address space (kbytes) unlimited
-l: locked-in-memory size (kbytes) unlimited
-u: processes 709
-n: file descriptors 8192
On Mavericks its simple. As a regular user:
ulimit -n 8192
You can check the updated settings via
ulimit -a
On my machine:
ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-v: address space (kbytes) unlimited
-l: locked-in-memory size (kbytes) unlimited
-u: processes 709
-n: file descriptors 8192
edited Oct 15 '14 at 17:56
answered Sep 4 '14 at 15:44
ClustermagnetClustermagnet
2991611
2991611
2
Consider revising your solution. You're setting a ulimit of 1024, then showing the output file descriptors as 8192 (should be 1024). You're approach is also probelmatic without sudo, try changing it a few times for yourself.
– y3sh
Oct 15 '14 at 13:34
1
sudo should not be used here but this answer is incorrect. Mavericks users should useecho limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and then restart their machine
– Kyle Chadha
Mar 17 '15 at 22:12
add a comment |
2
Consider revising your solution. You're setting a ulimit of 1024, then showing the output file descriptors as 8192 (should be 1024). You're approach is also probelmatic without sudo, try changing it a few times for yourself.
– y3sh
Oct 15 '14 at 13:34
1
sudo should not be used here but this answer is incorrect. Mavericks users should useecho limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and then restart their machine
– Kyle Chadha
Mar 17 '15 at 22:12
2
2
Consider revising your solution. You're setting a ulimit of 1024, then showing the output file descriptors as 8192 (should be 1024). You're approach is also probelmatic without sudo, try changing it a few times for yourself.
– y3sh
Oct 15 '14 at 13:34
Consider revising your solution. You're setting a ulimit of 1024, then showing the output file descriptors as 8192 (should be 1024). You're approach is also probelmatic without sudo, try changing it a few times for yourself.
– y3sh
Oct 15 '14 at 13:34
1
1
sudo should not be used here but this answer is incorrect. Mavericks users should use
echo limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and then restart their machine– Kyle Chadha
Mar 17 '15 at 22:12
sudo should not be used here but this answer is incorrect. Mavericks users should use
echo limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and then restart their machine– Kyle Chadha
Mar 17 '15 at 22:12
add a comment |
On OS X 10.13.6 this works for me:
$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 10240
$ sudo sysctl -w kern.maxfiles=1048600
kern.maxfiles: 12288 -> 1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
kern.maxfilesperproc: 10240 -> 1048576
$ ulimit -S -n
256
$ ulimit -S -n 1048576
$ ulimit -S -n
1048576
add a comment |
On OS X 10.13.6 this works for me:
$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 10240
$ sudo sysctl -w kern.maxfiles=1048600
kern.maxfiles: 12288 -> 1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
kern.maxfilesperproc: 10240 -> 1048576
$ ulimit -S -n
256
$ ulimit -S -n 1048576
$ ulimit -S -n
1048576
add a comment |
On OS X 10.13.6 this works for me:
$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 10240
$ sudo sysctl -w kern.maxfiles=1048600
kern.maxfiles: 12288 -> 1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
kern.maxfilesperproc: 10240 -> 1048576
$ ulimit -S -n
256
$ ulimit -S -n 1048576
$ ulimit -S -n
1048576
On OS X 10.13.6 this works for me:
$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 10240
$ sudo sysctl -w kern.maxfiles=1048600
kern.maxfiles: 12288 -> 1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
kern.maxfilesperproc: 10240 -> 1048576
$ ulimit -S -n
256
$ ulimit -S -n 1048576
$ ulimit -S -n
1048576
answered Dec 21 '18 at 14:43
Petr JavorikPetr Javorik
1112
1112
add a comment |
add a comment |
Some limits cannot be changed by ulimit
, because they only apply to the current shell, therefore launchctl
command should be used to change the limits globally, e.g.
sudo launchctl limit maxfiles 100000 unlimited
Please note that applying these limits in /etc/launchd.conf
(as suggested in other answers) is no longer supported in the recent macOS releases. Although can still use launchd.plist
(see: man launchd.plist
) such as per-user or system-wide plist
configuration files as suggested here and there.
To make these limits persistent, you can use /etc/sysctl.conf
file and add for example:
kern.maxprocperuid=1000
kern.maxproc=2000
kern.maxfilesperproc=20000
kern.maxfiles=50000
For changes to take the effect, it requires reboot.
To see the current limits, run: launchctl limit
or sysctl -a | grep ^kern.max
.
See also: How to persist ulimit settings in macOS?
add a comment |
Some limits cannot be changed by ulimit
, because they only apply to the current shell, therefore launchctl
command should be used to change the limits globally, e.g.
sudo launchctl limit maxfiles 100000 unlimited
Please note that applying these limits in /etc/launchd.conf
(as suggested in other answers) is no longer supported in the recent macOS releases. Although can still use launchd.plist
(see: man launchd.plist
) such as per-user or system-wide plist
configuration files as suggested here and there.
To make these limits persistent, you can use /etc/sysctl.conf
file and add for example:
kern.maxprocperuid=1000
kern.maxproc=2000
kern.maxfilesperproc=20000
kern.maxfiles=50000
For changes to take the effect, it requires reboot.
To see the current limits, run: launchctl limit
or sysctl -a | grep ^kern.max
.
See also: How to persist ulimit settings in macOS?
add a comment |
Some limits cannot be changed by ulimit
, because they only apply to the current shell, therefore launchctl
command should be used to change the limits globally, e.g.
sudo launchctl limit maxfiles 100000 unlimited
Please note that applying these limits in /etc/launchd.conf
(as suggested in other answers) is no longer supported in the recent macOS releases. Although can still use launchd.plist
(see: man launchd.plist
) such as per-user or system-wide plist
configuration files as suggested here and there.
To make these limits persistent, you can use /etc/sysctl.conf
file and add for example:
kern.maxprocperuid=1000
kern.maxproc=2000
kern.maxfilesperproc=20000
kern.maxfiles=50000
For changes to take the effect, it requires reboot.
To see the current limits, run: launchctl limit
or sysctl -a | grep ^kern.max
.
See also: How to persist ulimit settings in macOS?
Some limits cannot be changed by ulimit
, because they only apply to the current shell, therefore launchctl
command should be used to change the limits globally, e.g.
sudo launchctl limit maxfiles 100000 unlimited
Please note that applying these limits in /etc/launchd.conf
(as suggested in other answers) is no longer supported in the recent macOS releases. Although can still use launchd.plist
(see: man launchd.plist
) such as per-user or system-wide plist
configuration files as suggested here and there.
To make these limits persistent, you can use /etc/sysctl.conf
file and add for example:
kern.maxprocperuid=1000
kern.maxproc=2000
kern.maxfilesperproc=20000
kern.maxfiles=50000
For changes to take the effect, it requires reboot.
To see the current limits, run: launchctl limit
or sysctl -a | grep ^kern.max
.
See also: How to persist ulimit settings in macOS?
answered Jul 29 '17 at 13:27
kenorbkenorb
10.9k1578112
10.9k1578112
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f302754%2fincrease-the-maximum-number-of-open-file-descriptors-in-snow-leopard%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
This question's answers no longer work in OSX Mavericks.
– Howard
Jan 7 '14 at 10:02
2
Running
echo limit maxfiles 10000 10000|sudo tee -a /etc/launchd.conf
and restarting works for me in Mavericks.– user495470
May 30 '14 at 17:40