linux c 内存泄露检查 mtrace() 笔记

mtrace内存泄漏检测
本文介绍mtrace函数的使用方法,该函数用于安装malloc、realloc和free的调试处理器,通过设置环境变量MALLOC_TRACE指定输出文件,可用于检测内存泄漏。

$ man mtrace

只可以用与检查 malloc 的泄露. 怎么用?可以在网上查

NAME
       mtrace, muntrace - malloc debugging


SYNOPSIS
       #include <mcheck.h>


       void mtrace(void);


       void muntrace(void);


DESCRIPTION
       The  function  mtrace()  installs handlers for malloc(3), realloc(3) and
       free(3).  The function muntrace() disables these handlers.
       The environment variable MALLOC_TRACE  defines  a  file  where  mtrace()
       writes  its  output.  This file must be writable to the user or mtrace()
       will do nothing.  If the file is not empty it will be truncated.


CONFORMING TO
       These are GNU extensions.


NOTES
       The output of mtrace() will be ASCII but not in a friendly  format.   So
       glibc comes with a perl-script called mtrace to make sense of it.


SEE ALSO
       malloc(3), malloc_hook(3)


COLOPHON
       This  page  is  part  of release 3.22 of the Linux man-pages project.  A
       description of the project, and information about reporting bugs, can be
       found at http://www.kernel.org/doc/man-pages/.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值