Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If valgrind doesn't solve it - you can try tracking memory allocation yourself.</p> <p>There are two ways - replace your calls to malloc with calls to your own versions of malloc and free, and also pass in to those functions some kind of identifier, like <strong>FILE</strong> and <strong>LINE</strong>, or you can pass in the name of the system that is allocating.</p> <p>In non-memory leak detection mode you pass through directly to malloc and free, and in memory leak detection mode you first log the alloc and free calls and then call through to malloc and free. When the program finishes you match up the allocations and frees, and you'll see where you're leaking memory.</p> <p>You can do this with macros, so your regular build won't be slowed down.</p> <p>You won't catch leaks from client libraries that you can't recompile yourself.</p> <p>Another way is to use gcc's -wrap flag to at link time have gcc call your version of malloc/free instead of the glibc one. See this post:</p> <p><a href="https://stackoverflow.com/questions/262439/create-a-wrapper-function-for-malloc-and-free-in-c">Create a wrapper function for malloc and free in C</a></p> <p>The advantage of this is that you will be able to log allocations in client libraries as well. The disadvantage is that you are limited to the same function signature, so you won't be able to get <strong>FILE</strong> and <strong>LINE</strong> in your leak checker.</p> <p>If this was C++ you could overload global operator new.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload