Provided by: memleax_1.1.1-1_amd64 bug

NAME

       memleax - debugs memory leak of a running process

SYNOPSIS

       memleax [options] target-pid

DESCRIPTION

       memleax  debugs  memory  leak  of  a running process by attaching it.  It hooks the target
       process's invocation of memory allocation and free, and reports the  memory  blocks  which
       live  long  enough  as  memory  leak,  in  real  time.  The default expire threshold is 10
       seconds, however you should always set it by -e option according to your scenarios.

       There is no need to recompile the program or restart the target process.  You run  memleax
       to monitor the target process, wait for the real-time memory leak report, and then kill it
       (e.g. by Ctrl-C) to stop monitoring.

       memleax follows new threads, but not forked processes.  If  you  want  to  debug  multiple
       processes, just run multiple memleax.

OPTIONS

       You  should  always  set  -e according to your scenarios.  While other options are good in
       most instances with default values.

       -e expire
              Specifies memory free expire threshold in seconds. Default  is  10.   An  allocated
              memory  block  is reported as memory leak if it lives longer than this.  You should
              always set this according to your scenarios.  For example, if you are debugging  an
              HTTP server with keepalive, and there are connections last for more than 5 minutes,
              you should set `-e 360` to cover it.  If your program is  expected  to  free  every
              memory in 1 second, you should set `-e 2` to get report in time.

       -d debug-info-file
              Specifies separate debug information file.

       -l backtrace-limit
              Specifies  the  limit of backtrace levels. Less level, better performance.  Default
              is 50, which is also the max.

       -m memory-block-max
              Stop monitoring if there are so many expired memory  block  at  a  same  CallStack.
              Default is 1000.

       -c call-stack-max
              Stop monitoring if there are so many CallStack with memory leak.  Default is 1000.

       -h     Print help and quit.

       -v     Print version and quit.

OUTPUT

       The memory blocks live longer than the threshold, are showed as:

              CallStack[3]: memory expires with 101 bytes, backtrace:
                  0x00007fd322bd8220  libc-2.17.so  malloc()+0
                  0x000000000040084e  test  foo()+14  foo.c:12
                  0x0000000000400875  test  bar()+37  bar.c:20
                  0x0000000000400acb  test  main()+364  test.c:80

       `CallStack[3]` is the ID of CallStack where memory leak happens.

       The  backtrace is showed only on the first time, while it only shows the ID and counter if
       expiring again:

              CallStack[3]: memory expires with 101 bytes, 2 times again

       If the expired memory block is freed later, it shows:

              CallStack[6]: expired-memory frees after 10 seconds

       If there are too many expired-memory-blocks are freed on  one  CallStack,  this  CallStack
       will not be showed again:

              Warning: too many expired-free at CallStack[6]. will not show this CallStack later

       When you think you have found the answer, stop the debug.

       memleax quits on:

       * you stop it, by Ctrl-C or kill,

       * the target process quits,

       * too many leaks at one CallStack (option -m), or

       * too many CallStacks with memory leak (option -c).

       After quitting, it also gives statistics for the CallStacks with memory leak:

              CallStack[3]: may-leak=20 (2020 bytes)
                  expired=20 (2020 bytes), free_expired=0 (0 bytes)
                  alloc=20 (2020 bytes), free=0 (0 bytes)
                  freed memory live time: min=0 max=0 average=0
                  un-freed memory live time: max=20
                  0x00007fd322bd8220  libc-2.17.so  malloc()+0
                  0x000000000040084e  test  foo()+14  foo.c:12
                  0x0000000000400875  test  bar()+37  bar.c:20
                  0x0000000000400acb  test  main()+364  test.c:80

AUTHOR

       Written by Wu Bingzheng.

       Project GitHub: https://github.com/WuBingzheng/memleax