Skip to content

Instantly share code, notes, and snippets.

@delcypher
Created April 22, 2014 09:16
Show Gist options
  • Save delcypher/11171403 to your computer and use it in GitHub Desktop.
Save delcypher/11171403 to your computer and use it in GitHub Desktop.
Testing if mallinfo.uordblks includes mmaped memory
#include <stdio.h>
#include <malloc.h>
int main(int argc, char** argv)
{
struct mallinfo mi;
mi = mallinfo();
printf("BEFORE:\nuordblks:%d\nhblkhd:%d\n\n", mi.uordblks, mi.hblkhd);
malloc_stats();
printf("\n\nDOING malloc\n\n");
char* a = malloc( 256 << 20 ); // Ask for 256MB
mi = mallinfo();
printf("AFTER:\nuordblks:%d\nhblkhd:%d\n\n", mi.uordblks, mi.hblkhd);
malloc_stats();
a[0] = 'a';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment