#include #include #include #include #include #include #if defined RLIMIT_AS # define ZZUF_RLIMIT_MEM RLIMIT_AS #warning using RLIMIT_AS #elif defined RLIMIT_VMEM # define ZZUF_RLIMIT_MEM RLIMIT_VMEM #warning using RLIMIT_VMEM #elif defined RLIMIT_DATA # define ZZUF_RLIMIT_MEM RLIMIT_DATA #warning usign RLIMIT_DATA #else # undef ZZUF_RLIMIT_MEM #error RLIMIT does not support memory limiting #endif int main(void) { int err; struct rlimit rlim; rlim.rlim_cur = 256 * 1024 * 1024; rlim.rlim_max = 256 * 1024 * 1024; err = setrlimit(ZZUF_RLIMIT_MEM, &rlim); if (err == -1) { error(1, errno, "setrlimit failed"); return EXIT_FAILURE; } volatile char *tmp = malloc(375390457); for (int i = 0; i < 1024; i++) tmp[0x90 * 1024 * i] = i; return EXIT_SUCCESS; } /* vim: set sw=2 ts=2 et: */