aboutsummaryrefslogtreecommitdiff
path: root/tests/mem.c
blob: c144bfc1d9c1b683b904853379ccc0e4f8f3f83b (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 = 5;
    for (;;mb += 5) {
        fprintf(stderr, "%lu MB\n", mb);
        if ((ptr = realloc(ptr, mb * 1000000)) == NULL) {
            raise(SIGABRT);
        }
    }
}