I need to increase the default stack size on Linux. As I know there are usually two ways:

  • ulimit -s size
  • /etc/security/limits.conf

The ulimit method only works as long as I am logged in.

limits.conf will work after a restart.

Is there a possible way to increase the limit without restarting?

  • There must be a way to do this. The ulimit shell command doesn't work for a user. And the current logged in user doesn't have permission to alter their limit unless they are root.
    – hookenz
    Dec 21, 2012 at 1:45
  • Did you find the answer? Apr 6, 2021 at 1:39

4 Answers 4


What's wrong with editing your .bashrc file to do a ulimit -s size every time you start a terminal session?

  • unfortunately that is not for me as a user, it is for the couchdb process, which crashes because a document in the DB is to big to fit in the stack.
    – Simon
    Jul 21, 2011 at 11:17
  • @Simon: that means you're currently restarting that process every time? How is that done? Can't you splice the ulimit -s size in the scripts that control the restarts?
    – MSalters
    Jul 21, 2011 at 12:48
  • well, it is a subprocess of couchdb that crashes (couchjs). So all processes started by the user couchdb should have a bigger stack
    – Simon
    Jul 21, 2011 at 13:07

If you want to do this programatically, you can use the setrlimit() function.

  • unfortunately I need to set the limit for couchdb, not for a program of my own. So setting it programatically is out of question
    – Simon
    Jul 21, 2011 at 11:17

Linux (and POSIX compatible systems in general) inherit current process limits from existing processes when a new process is started (using fork() or exec()). As a result, you would just need to change the limits for all existing processes that are already running on your system. The config files just define the values for the initial processes after the system has been booted and everything else inherits the current values of parent processes.

Why would you want to increase stack limit of everything? Do all your existing processes immediately require increased stack space for some reason?

If you actually need to change the limits of any given process after that process has already been started, you can do it with command prlimit which uses kernel interface int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit) behind the scenes. It requires CAP_SYS_RESOURCE for many use cases so you often need to run that as root in practice.


limits.conf don't need a restart.

It just needs a new session to work.

You need to logout and login.

You must log in to answer this question.

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