Git Product home page Git Product logo

memory_leak_checker's Introduction

Memory Leak Checker

软件介绍

Memory Leak Checker是使用malloc的hook机制来检查软件内存泄漏问题,并且使用了libunwind来获取泄漏地址的堆栈信息。
该软件支持malloc/new,并且支持多线程(valgrind 在多线程环境下会有比较大的问题),使用时只需要将mem_leak_checker头文件包含在需要监控的文件内即可,但是机器上必须安装libunwind库。

API介绍

void mem_leak_checker_init();

初始化底层数据结构,在main函数的启动前调用。为了方便代码往c语言移植,我们并没有使用c++的面向对象特性来编写代码,所以移植到c语言非常方便。

pthread_mutex_t* get_lock();
void start_hook();
void stop_hook();

对于大型的项目,底层会有大量的malloc调用,由于malloc_hook底层使用了libuwind来获取堆栈信息,所以会大幅度降低程序性能. 因此Memory Leak Checker支持按照一定区块来监控,示例代码见main文件。

void mem_leak_checker_detail();

在main函数末尾,获取泄漏的内存信息

void mem_leak_checker_clear();

显式清理泄漏的内存

编译

如果你使用blade,我也为你写好了BUILD文件。
你也可以使用g++来编译: g++ hash.cpp main.cpp mem_leak_checker.cpp stack_trace.cpp -lpthread -lunwind -o main

memory_leak_checker's People

Contributors

aronlt avatar

Stargazers

古格 avatar 煎饼果子 avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.