6

macOS Sierra introduced us to the ulimit-Justin-Bieber-restriction. Thanks, Apple!

According to this tutorial you can set ulimit max manually by creating two files. In the tutorial max. processes is at 2048.

Did this. Problem is: my max. processes per user is 2500. Found out via try & error. Great stuff!

Why? Why can't I go over this number? Tried 2600, after reboot uname -a shows 1064. What is this number, why exactly 1064? Why am I limited in user processes anyway? The default number was 709...

P.S.: for those who wonder why I need such a "high" number: it's because of JMeter and the thread handling there. If I don't manually edit the maxproc, JMeter just won't run properly. Or not at all.

3
  • IIRC the hard limit is 2500 for every 8 GB of installed RAM (e.g. 32 GB > 10,000 maxproc) – klanomath Aug 23 '17 at 23:00
  • 1
    OK, but due to the fact that my machine offers 16GB the maximum should be 5000... – c1ph4 Aug 24 '17 at 7:09
  • The hard limit on maxproc and maxprocperuid is only increased if you have Server Performance Mode turned on (serverperfmode=1) and 16 GiB or more memory installed. See What does serverperfmode=1 actually do?. – Old Pro Oct 21 '19 at 18:07
5

TL;DR

  • The method for increasing max. processes per user described in the tutorial the OP referenced is both dangerous and ineffective. Do not do it that way. If you need more user processes, enable Server Performance Mode as described here.
  • "What is this number, why exactly 1064?" See Why is macOS limited to 1064 or 2088 processes?
  • "Why am I limited in user processes anyway?" Because the system can only run a limited number of processes at once, the system limits users to a lower number of processes so that the system itself remains able to run processes, for example one to display a warning that you have run out of of processes.

Details

The articles the OP linked to are DANGEROUS because they install configurations that allow a single user to crash the computer by filling up the process table, meaning they can create as many processes as the system will allow (well, probably minus 2 or so reserved for root, which was a kind of protection against this in the old days when 2 processes were enough for a system administrator to get in and fix problems). They also install those configurations in a way for which there is no automatic or easy rollback once you forget that you set them or how you set them, and they may interfere with future default increases when you upgrade to a new OS version. More importantly, they do not really achieve what they claim to achieve with regard to increasing the number of processes a user can run.

The default hard limit for kern.maxproc (the maximum total number of processes that can run at one time systemwide) under OS X is 1064. The limit was 566 until OS X Lion, at which point it was increased to 1064 for computers with 3 GiB or more of memory. The limit was increased again in High Sierra for computers with 12 GiB or more memory (exact formula is detailed in the description of serverperfmode here.) and increased again in Catalina (and my guess is it will be increased again in Big Sur). (See Why is macOS limited to 1064 or 2088 processes? for more details about where the specific numbers like 1064 came from.) Although you can change the number while the system is running, it does not take immediate effect; you have to set it during the boot process to take effect and at that point the kernel will not go above 1064 (or whatever limit you are already seeing).

You can set kern.maxprocperuid (the maximum number of processes a single user can have running at one time) to a higher number, even higher than kern.maxproc, but having it too high risks having an out-of-control process crash the entire machine by filling up the process table. That is why the default maxprocperuid is 709 which is 2/3 of 1064: to ensure a single user cannot take up all the processes.

Server Performance Mode

Before High Sierra, the only way to increase kern.maxproc above 1064 is to have at least 16 GiB of memory installed and the to turn on "Server Performance Mode", which reconfigures the kernel to operate like a server rather than an interactive workstation. Starting with High Sierra you can increase kern.maxproc by adding more memory, but still, short of adding memory, the only way to increase it is by turning on "Server Performance Mode". In that mode, kern.maxproc is set to floor(system_memory/8 GiB) * 2500. You also get much higher limits on many other parameters, like max open files and max network connections. You get these higher limits automatically, without having to create or modify files like the linked articles tell you to.

If sysctl kern.maxproc returns kern.maxproc: 1064 (or any multiple of 532 or 1044) then you know you do not have server performance mode turned on. To turn it on, execute this command line in the terminal:

sudo nvram boot-args="serverperfmode=1 $(nvram boot-args 2>/dev/null | cut -f 2-)"

and reboot. That setting will persist and your computer will remain in server mode until you clear NVRAM completely or turn Server Performance Mode off by executing

sudo nvram boot-args="$(nvram boot-args 2>/dev/null | sed -e $'s/boot-args\t//;s/serverperfmode=1//')"

Turning on Server Performance Mode is safer and easier than trying to change individual kernel parameters by editing configuration files, and it has the added advantage of working where those other things will not. And unlike editing configuration files, is also automatically rolled back when you clear NVRAM, which is a standard part of restoring a misconfigured computer to a standard and sane configuration.

You can read more about this Fix “fork: resource temporarily unavailable” on OS X.

1
  • " is safer" — you're saying it like it will drop a bomb all of the sudden. C'mon, Apple's OS panics just fine w/o any changes. – poige Nov 22 '19 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .