I'm writing a C program and am exceeding the recursion limit via a segmentation fault. Is there any way to increase the program's recursion limit (perhaps via increasing the stack size), either via an option to GCC or via a command-line option? The program is running on Ubunutu.
You can change the stack size with ulimit
on Linux, for example:
ulimit -s unlimited
On Windows with Visual Studio, use /F
option.
The stack size is a function of the operating system, though many earlier operating systems (MSDOS for example) didn't do program stack segment control: it was up to the program to reserve an adequately sized segment.
With virtual memory and 32-bit APIs, the stack size is usually provided by a resource management mechanism. For example, on Linux, the ulimit
command provides one source of stack size control. Other levels of control are provided by mechanisms inside the kernel enforcing system policy, memory limitations, and other limits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With