Giter Club home page Giter Club logo

memtrail's Introduction

About

memtrail is a LD_PRELOAD based memory profiler and leak detector for Linux.

There are already many other open-source memory debugging/profiling tools for Linux, several of which are listed on Links section below, and the most powerful arguably being Valgrind. However, I needed a tool that could quantify leaks and identify memory hogs, for long-running and CPU intensive workloads, which simply run too slow under Valgrind's dynamic binary instrumentation, hence this project.

Features

  • Very little runtime overhead

  • Will immediately output maxmimum memory allocated and total leaked memory at the end of program execution.

  • Text trees show callstacks for memory consuption or leaks

  • Can produce graphs showing flow of memory consumption or leaks

Requirements

Build

make

Usage

Run the application you want to debug as

memtrail record /path/to/application [args...]

and it will generate a record memtrail.data in the current directory.

View results with

memtrail report

It will produce something like

maximum: 5890 bytes

->34.77% (2048B): test_calloc
| ->34.77% (2048B): main
|   ->34.77% (2048B): __libc_start_main
|     ->34.77% (2048B): _start
| 
->17.39% (1024B): test_memalign
| ->17.39% (1024B): main
|   ->17.39% (1024B): __libc_start_main
|     ->17.39% (1024B): _start
| 
->17.39% (1024B): test_malloc
| ->17.39% (1024B): main
|   ->17.39% (1024B): __libc_start_main
|     ->17.39% (1024B): _start
| 
-> 8.69% (512B): TestGlobal::TestGlobal()
| -> 8.69% (512B): __static_initialization_and_destruction_0
|   -> 8.69% (512B): _GLOBAL__sub_I_leaked
|     -> 8.69% (512B): __libc_csu_init
|       -> 8.69% (512B): __libc_start_main
|         -> 8.69% (512B): _start
| 
-> 8.69% (512B): test_cxx
| -> 8.69% (512B): main
|   -> 8.69% (512B): __libc_start_main
|     -> 8.69% (512B): _start
| 
-> 8.69% (512B): test_cxx
| -> 8.69% (512B): main
|   -> 8.69% (512B): __libc_start_main
|     -> 8.69% (512B): _start
| 
-> 4.35% (256B): TestGlobal::TestGlobal()
| -> 4.35% (256B): __static_initialization_and_destruction_0
|   -> 4.35% (256B): _GLOBAL__sub_I_leaked
|     -> 4.35% (256B): __libc_csu_init
|       -> 4.35% (256B): __libc_start_main
|         -> 4.35% (256B): _start
| 
-> 0.02% (1B) in 2 places, all below the 1.00% threshold

memtrail.maximum.json written

You can then use gprof2dot.py to obtain graphs highlighting memory leaks or consumption:

gprof2dot.py -f json memtrail.maximum.json | dot -Tpng -o memtrail.maximum.png

Sample

#include "memtrail.h"

...

   memtrail_snapshot();

Links

Memory debugging:

Memory profiling:

Catalogs:

memtrail's People

Contributors

godspeed1989 avatar jrfonseca avatar

Watchers

 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.