linux 下dmalloc安装及环境配置

本文详细介绍了dmalloc内存调试工具的下载、安装步骤,并提供了如何配置环境变量及使用dmalloc进行内存泄漏检测的方法。此外还给出了一个简单的测试程序示例及其编译指令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 ***

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值