Skip to content

Instantly share code, notes, and snippets.

@KunYi
Created May 31, 2018 05:02
Show Gist options
  • Save KunYi/9b49bcee08493e5af7b548ae52ac466a to your computer and use it in GitHub Desktop.
Save KunYi/9b49bcee08493e5af7b548ae52ac466a to your computer and use it in GitHub Desktop.
for stack size testing
#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