$ man 2 getrlimit
Linux resource limits reference
Every process carries 16 soft and hard limits, and one of them being lower than anyone assumed is a common reason a service works on one box and not another. Each limit below has its own page with its resource number, the row it occupies in/proc/PID/limits, the bash ulimit flag, and what fails when you hit it.
The soft limit is what the kernel enforces. The hard limit is the ceiling an unprivileged process may raise its own soft limit to, and it can only be lowered, not raised, without privilege (details differ for RLIMIT_NOFILE, which is also capped by /proc/sys/fs/nr_open). Children inherit both across fork and execve, which is why a daemon started from a script keeps whatever the script set. Numbers come fromasm-generic/resource.h; behaviour followsgetrlimit(2). The BSDs have the same call with a different list; the FreeBSD per-jail answer is inthe rctl Tip.
What you saw, and which limit it points at
- Too many open files (EMFILE)RLIMIT_NOFILE
- Cannot fork: Resource temporarily unavailable (EAGAIN)RLIMIT_NPROC
- Cannot allocate memory (ENOMEM) with RAM freeRLIMIT_AS, RLIMIT_DATA, RLIMIT_MEMLOCK
- File size limit exceededRLIMIT_FSIZE
- CPU time limit exceededRLIMIT_CPU, RLIMIT_RTTIME
- No core file was writtenRLIMIT_CORE
- Segfault on deep recursion, or exec fails with E2BIGRLIMIT_STACK
- Cannot switch to a real-time scheduler (EPERM)RLIMIT_RTPRIO
These are pointers, not diagnoses: ENOMEM and EAGAIN have other causes, including cgroup limits and system-wide exhaustion.
Read a /proc/PID/limits dump
Run cat /proc/PID/limits against the process that is misbehaving (not your login shell) and paste the output. Nothing leaves your browser.
16 limits
Files and descriptors
- RLIMIT_FSIZEulimit -f · bytes
Maximum size of a file the process may create or extend.
- RLIMIT_COREulimit -c · bytes
Maximum size of a core dump.
- RLIMIT_NOFILEulimit -n · files
One more than the highest file descriptor number the process may open.
Memory
- RLIMIT_DATAulimit -d · bytes
Maximum size of the data segment: initialized data, uninitialized data and the heap.
- RLIMIT_STACKulimit -s · bytes
Maximum size of the main thread stack.
- RLIMIT_MEMLOCKulimit -l · bytes
Maximum bytes the process may lock into RAM.
- RLIMIT_ASulimit -v · bytes
Maximum size of the process virtual address space.
Processes and signals
- RLIMIT_NPROCulimit -u · processes
Maximum number of processes and threads for the real user ID.
- RLIMIT_SIGPENDINGulimit -i · signals
Maximum number of signals that may be queued for the real user ID.
CPU time and scheduling
- RLIMIT_CPUulimit -t · seconds
Maximum CPU time the process may use.
- RLIMIT_NICEulimit -e · priority (see note)
Ceiling for how far the process may raise its own priority with nice or setpriority.
- RLIMIT_RTPRIOulimit -r · priority
Ceiling on the real-time priority the process may set with sched_setscheduler or sched_setparam.
- RLIMIT_RTTIMEulimit -R · microseconds
CPU time a real-time scheduled process may use without making a blocking system call.
Queues
- RLIMIT_MSGQUEUEulimit -q · bytes
Maximum bytes the real user ID may allocate to POSIX message queues.
Obsolete on Linux
- RLIMIT_RSSulimit -m · bytes
Resident set size limit. The kernel does not enforce it on modern Linux.
- RLIMIT_LOCKSulimit -x · locks
Limit on flock(2) locks and fcntl(2) leases. Early Linux 2.4 only.
No match. Try the name without RLIMIT_, the error name, or the ulimit flag, or search the whole site.
Sources: getrlimit(2), proc_pid_limits(5), help ulimit in bash. Spot one that's wrong?Tell Rod.