1 download dmalloc-5.4.2.gz from website http://sourceforge.net/projects/dmalloc/files/Dmalloc/5.4.2/dmalloc-5.4.2.tgz/download
2 install
Tar zxvf dmalloc-5.4.2.tgz
CD dmalloc-5.4.2
./Configure -- prefix =/usr/local/dmalloc -- libdir =/usr/lib -- enable-threads -- enable-shlib
Make
Make install
3. Locate *. So, dmalloc, and dmalloc. h after installation.
4 In ~ /. Add function dmalloc {eval 'COMMAND dmalloc-B $ * ';} To bashrc *';}
5 source ~ /. Bashrc
6 dmalloc-L ~ /Y-I 100 low
Set export dmalloc_options = DEBUG = 0x4e48503, Inter = 100, log =/home/Ubuntu/y
7. Write and TestProgram
# Include <stdio. h>
# Include <stdlib. h>
# Ifdef dmalloc
# Include <dmalloc. h>
# Endif
Int main (INT argc, char * argv []) {
Int * inew;
Inew = new int [10];
Printf ("this is test/R/N ");
Return 0;
}
8. Compile
G ++-D dmalloc -ddmalloc_func_check -I/usr/local/dmalloc/include ***. CPP-ldmalloc-O ***