aboutsummaryrefslogtreecommitdiff
path: root/tests/mem.c
blob: 36ad3a9d82304bec8b61377b3b88017537ccb608 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

/* mem.c -- Exhaust your memory */
int main(void){
    void *ptr = NULL;
    unsigned long mb = 1;
    for (;;mb++) {
        fprintf(stderr, "%lu MB\n", mb);
        if ((ptr = realloc(ptr, mb * 1000000)) == NULL) {
            raise(SIGABRT);
        }
    }
}