mtrace


#include 
#include 
#include 

int main() {
  int i = 10;
  char *p = NULL;
  mtrace();
  while (i--) {
    p = malloc(32);
    sleep(1);
  }
  free(p);
  return 0;
}

gcc -g -o memcheck memcheck.c

MALLOC_TRACE=/home/junlon2006/Workspace/study/test/mem.log

mtrace  memcheck mem.log

你可能感兴趣的:(linux/kernel)