现在的位置: 首页 > 综合 > 正文

linux 下dmalloc安装及环境配置

2012年06月17日 ⁄ 综合 ⁄ 共 767字 ⁄ 字号 评论关闭

1  从网站 http://sourceforge.net/projects/dmalloc/files/Dmalloc/5.4.2/dmalloc-5.4.2.tgz/download 下载dmalloc-5.4.2.gz

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   找到*.so、dmalloc 及dmalloc.h安装后的位置

 

4   在~/.bashrc中添加function dmalloc { eval 'command dmalloc -b $*'; } 
5   source ~/.bashrc 
6    dmalloc -l ~/y -i 100 low
        将export  DMALLOC_OPTIONS=debug=0x4e48503,inter=100,log=/home/ubuntu/y

7   编写测试程序

 

#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   编译

     g++ -DDMALLOC -DDMALLOC_FUNC_CHECK -I/usr/local/dmalloc/include ***.cpp -ldmalloc -o ***

抱歉!评论已关闭.