Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created January 21, 2018 06:50
Show Gist options
  • Save kaityo256/40790bc3ce51b2235e3ae9ca3d99eeef to your computer and use it in GitHub Desktop.
Save kaityo256/40790bc3ce51b2235e3ae9ca3d99eeef to your computer and use it in GitHub Desktop.
Test for mmapped arena
#include <cstdio>
#include <cstdlib>
#include <omp.h>
const int N = 128;
int
main(void){
char *buf[N];
#pragma omp parallel for
for(int i=0;i<N;i++){
buf[i] = (char*)malloc(128);
}
for(int i=0;i<N;i++){
size_t *p = (size_t*)buf[i];
if (*(p-1) & 4){
printf("mmapped arena is used.\n");
goto label;
}
}
label:
for(int i=0;i<N;i++){
free(buf[i]);
buf[i][0] = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment