Difference between ulimit, launchctl, sysctl

launchctlmac-osxsysctlulimit

When managing the limits of the operating system (specifically OSX), what is the difference and overlap between the functionality and history of these three tools:

  1. ulimit
  2. launchctl, launchd
  3. sysctl

I found it confusing to adjust the maximum processes and open files limits on OSX.

Does it matter if some processes are launched via the terminal versus the GUI?

Possibly related:

Best Answer

1. ulimit

This is a builtin command of your shell (bash/ash/zsh etc). It temporarily sets process limits for the current shell. This is not macOS specific by the way.

2. sysctl

Most unix-like (Linux/*BSD/macOS) systems set global limit/kernel settings via the sysctl command /etc/sysctl.conf config file.

Seems like macOS does not honor sysctl.conf on startup anymore. So on macOS, it looks like sysctl is merely usable for temporarily setting the global limits.

3. launchd / launchctl

For setting global limits in a persistent way, use launchctl on macOS.