Created
May 31, 2018 05:02
-
-
Save KunYi/9b49bcee08493e5af7b548ae52ac466a to your computer and use it in GitHub Desktop.
for stack size testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/time.h> | |
#include <sys/resource.h> | |
#include <stdio.h> | |
#include <alloca.h> | |
long long i; | |
int main(int argc, char** argv) { | |
char a; | |
struct rlimit rlim; | |
for (;;) { | |
getrlimit(RLIMIT_STACK, &rlim); | |
printf("soft=%dK, hard=%dK\n", | |
(int)rlim.rlim_cur/1024, | |
(int)rlim.rlim_max/1024); | |
printf("pid = %d", getpid()); | |
a = getchar(); | |
if (a == 'e') break; | |
for (i=0; i< 8192*1024 ; i ++ ) { | |
alloca(1024); | |
printf("%8lld kb\n",i); | |
} | |
printf("sucess, i = %lld\n", i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment