skip to Main Content

this is a rather simple question.

In my school we use a remote CentOS server to compile and test our programs. For some reason, valgrind always shows a 4096B leak in spite of the fact that no malloc was used. Does anyone here have any idea where this problem might stem from?

enter image description here

2

Answers


  1. Your program makes a call to printf. This library might allocate memory for its own usage. More generally, depending on the OS/libc/…, various allocations might be done just to start a program.

    Note also that in this case, you see that there is one block still allocated at exit, and that this block is part of the suppressed count. That means that valgrind suppression file already ensures that this memory does not appear in the list of leaks to be examined.

    In summary: no problem.

    In any case, when you suspect you have a leak, you can look at the details of the leaks e.g. their allocation stack trace to see if these are triggered by your application.

    Login or Signup to reply.
  2. In addition to @phd’s answer, there are a few things you can do to see more clearly what is going on.

    If you run Valgrind with -s or -v it will show details of the suppressions used.

    You can use --trace-malloc=yes to see all calls to allocation functions (only do that for small applications). Similarly you can run with --default-suppressions=no and than you will see the details of the memory (with --leak-check=full --show-reachable=yes in this case)

    Finally, are you using an old Centos / GNU libc? A few years ago Valgrind got a mechanism to cleanup things like io buffers so you shouldn’t get this sort of message with recent Valgrind and recent Linux + libc.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search