#include #include #include #include #include #include #include int main() { struct rlimit rl; int rc; unsigned long s = 1024*1024*10; /* 10 Megabytes */ unsigned long total = 0; char *m; int p; char *method; /* * Retrieve what we believe our limits to be */ rc = getrlimit(RLIMIT_DATA, &rl); if (rc < 0) { fprintf(stderr,"getrlimit: %s[%d]\n",strerror(errno),errno); exit(1); } printf("struct rlimit {\n"); printf(" rlim_t rlim_cur=%qu\n", rl.rlim_cur); printf(" rlim_t rlim_max=%qu\n", rl.rlim_max); printf("}\n"); /* * let's touch alot of memory */ #if 1 #define MAPIT(s) mmap(0,s,PROT_READ|PROT_WRITE,MAP_ANON|MAP_NOCORE,-1,0) method = "mmap"; while ((m=MAPIT(s)) != MAP_FAILED) { #else method = "malloc"; while ((m=malloc(s)) != NULL) { #endif total += s; for (p=0; p