title: Get the call stack in code with less overhead?
body: <p>I am going to implement an internal profiler for memory on linux. I want to save the stack for each malloc/free/realloc. I am trying to use "pstack" to get the stack trace everytime. But the overhead is too high. Is there any lightweigt approach to get the call stack in C code?</p>
  
  <p>I know there are some tools like "valgrind, google profiler", but don't know how they remebmer the stacks for each action.</p>
  
  <p>Any comment is appreciated.</p>
  
  <p>Thanks.</p>