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
our sponsors
latest post
- How To Root Your HTC Incredible S
- How can i use GCC in windows/cmd just like using gcc in linux terminal?
- how to increase stack size in linux.
- Equivalent to getch() & getche() in Linux
- Huffman Encoding Using Linked List with Source Code
latest comments
- saurabh on how to increase stack size in linux.
- jigar on how to increase stack size in linux.
- Diablo 3 on Huffman Encoding Using Linked List with Source Code
- diablo 3 classes on Implementation limitation of c programming language
- Cdecl – Best friend for c-language beginner , Know what your c code … | F1 Help on Cdecl – Best friend for c-language beginner | Know what your c code says
Find us on Facebook
tag cloud
Android Gingerbread Update Android NDK AVplayer best selling android phones bit-wise operator c c/c++ compilers c89 c90 c99 CLOC Dart Dart programming language Dynamic Languages Embedded Careers find and replace in linux gcc in windows getch() and getche() in linux Google announces Dart programming language google dart google new programming language how to count line of code IDE iPhone 4S iPhone 5 iphone siri Javascript limitation of c programming language linux tips MATLAB MoSync SDK NestedVM Octal literal Original Android Market php php mail project STRUCTURED WEB PROGRAMMING Undefined behaviour in c Valgrind wordpress
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.
Top Authors
Find us on stackoverflow
Polls
Categories
- Android (9)
- sample programme (1)
- Tips (9)
- c (14)
- sample programme (4)
- Tips (12)
- tutorials (2)
- c++ (7)
- sample programme (1)
- tips (6)
- linux (5)
- tips (5)
- Matlab (2)
- PHP & PHP Framworks (4)
- PHP (2)
- sample programs (1)
- Tips (1)
- Tutorials (1)
- wordpress (2)
- PHP (2)
- Uncategorized (9)
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