how to increase stack size in linux.
Normally you would set the stack size early on, e,g, at the start of main(), before calling any other functions. Typically the logic would be:
- call getrlimit to get current stack size
- if current size < required stack size then
- call setrlimit to increase stack size to required size
In C that might be coded something like this:
#include <sys/resource.h> int main (int argc, char **argv) { const rlim_t kStackSize = 64L * 1024L * 1024L; // min stack size = 64 Mb struct rlimit rl; int result; result = getrlimit(RLIMIT_STACK, &rl); if (result == 0) { if (rl.rlim_cur < kStackSize) { rl.rlim_cur = kStackSize; result = setrlimit(RLIMIT_STACK, &rl); if (result != 0) { fprintf(stderr, "setrlimit returned result = %d\n", result); } } } // ... return 0; }
You may like to read this also....
2 Comments to “how to increase stack size in linux.”
Post comment
Search in this website
our sponsors
latest comments
- Motasim billah on List of all standard version of c language
- kamal9211 on Top/Best C/C++ IDE for Windows & Linux
- kamlesh khot on Structure of a C-Program in Memory | How Heap,Stack,Data and Code segments are stored in memory?
- neha on List of all standard version of c language
- vamsi on List of all standard version of c language
Find us on Facebook
Top Authors
Find us on stackoverflow
Polls
Loading ...
My Bookmarks
- Audio/video Recorder & player application based on MATLAB
- check dependency of your binary
- defination of all standard c programming language function
- Great Question-Answer on c programming
- know what your c code means
- Limition of c programming language
- List of all version of c programming language
- Online c compiler
- php freelancing work
- some more stuff on C programming language
- Volatile Keyword in Embedded System
- Write Android application in c language
buddy stack size also can be increaese by this way
gcc -Wl,–stack,16777216 -o file.exe file.c
no need to do this all stuff in code…!!
jigar recently posted..how to increase stack size in linux.
Its Programmatic Way