Memory Profilers

Tool measure consumption detect leaks bound checking 3) C++ support footprint run embedded analysis tools
valgrind yes yes yes yes large no great
tcmalloc yes yes no yes ok ok ok, some tweaking
mudflap ? yes yes minimal 1) ok ok ok
dmalloc yes yes no ? ok not tried 2) no tried
electric fence ? ? yes


mudflap object 0x10aca18: name=`/usr/local/angstrom-eglibc-x86_64-armv5te/sysroots/armv5te-angstrom-linux-gnueabi/usr/include/c++/bits/vector.tcc:296:28 (std::vector<std::basic_string<char> >::_M_in'
Nearby object 2: checked region begins 229B after and ends 240B after

2) configure aborted

3) only valgrind or mudflap can do bound checks, the former since it emulates the CPU, the latter due to a separate compiler pass. electric fence uses the MMU to add a no-fly zone after each allocation so it finds buffer overruns, as long they are smaller then a page

heap protection

try to detect double free, or off-by-one bugs.

int foo()
  char *b = malloc(10);
  b[20] = 'c';
//  free(b);


  • replaces the heap library calls, malloc, free, realloc,
  • heap adds checksums before/after allocation (fence-post)
  • when realloc/free funciont, pointer is checked if valid
  • uses dmalloc util to create an environment variable DMALLOC_OPTONS
  • good manual, last release 2007-05-14


  • similar to dmalloc ** add special bytefields before/after allcoated memory ** when freeing(and maybe more often?) bytefields
  • simple, nice short manual



electric fence

  • uses MMU to detect buffer overflow,
  • one page per allocation, page table entry after allocation is prohibited.
    • buffer overflow will dereference address not backed by memory, catched by MMU
  • runs very fast, but uses a lot of memory, 4K per allocation



  • not sure about memory/performance penalty
  • dlmalloc/rnmalloc could be enabled by LD_PRELOAD upone request
  • mudflap probably needs separate dSS package