Is there a way to increase stack size / recursion?

I am writing a C program and will exceed the recursion limit through a segmentation error. Is it possible to increase the recursion limit of a program (possibly by increasing the size of the stack), either using the GCC option or the command line option? The program runs on Ubunutu.

+5
source share
2 answers

You can resize the stack using ulimit on Linux, for example:

 ulimit -s unlimited 

On Windows with Visual Studio, use the /F option.

+5
source

Stack size is a function of the operating system, although many earlier operating systems (for example, MSDOS) did not manage the segment of the program stack: it was a task to reserve a segment with the appropriate size.

In virtual memory and 32-bit APIs, the stack size is usually provided by the resource management mechanism. For example, on Linux, the ulimit command provides one source for controlling the size of the stack. Other levels of control are provided by mechanisms within the kernel that provide system policy, memory limits, and other restrictions.

+2
source

Source: https://habr.com/ru/post/1211796/


All Articles