2019-05-01 02:24:58 +05:30
|
|
|
#include <pthread.h>
|
2020-06-18 02:09:50 +05:30
|
|
|
#include <stdio.h>
|
2019-05-01 02:24:58 +05:30
|
|
|
|
|
|
|
#include <malloc.h>
|
|
|
|
|
2020-06-18 02:09:50 +05:30
|
|
|
#include "test_util.h"
|
|
|
|
|
|
|
|
OPTNONE static void leak_memory(void) {
|
2019-05-01 02:24:58 +05:30
|
|
|
(void)malloc(1024 * 1024 * 1024);
|
|
|
|
(void)malloc(16);
|
|
|
|
(void)malloc(32);
|
|
|
|
(void)malloc(4096);
|
|
|
|
}
|
|
|
|
|
2020-06-18 02:09:50 +05:30
|
|
|
static void *do_work(void *p) {
|
2019-05-01 02:24:58 +05:30
|
|
|
leak_memory();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
pthread_t thread[4];
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
pthread_create(&thread[i], NULL, do_work, NULL);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
pthread_join(thread[i], NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
malloc_info(0, stdout);
|
|
|
|
}
|