3

I am profiling my source. I see some allocations that are still alive at exit when I run valgrind.
Here is the summary:

$ valgrind --track-origins=yes --show-reachable=yes --leak-check=full $BINARY

...

==20235== LEAK SUMMARY:
==20235==    definitely lost: 0 bytes in 0 blocks
==20235==    indirectly lost: 0 bytes in 0 blocks
==20235==      possibly lost: 0 bytes in 0 blocks
==20235==    still reachable: 20,228 bytes in 37 blocks
==20235==         suppressed: 0 bytes in 0 blocks
==20235== 

The responsible libraries are:

dyld: all 81 mallocs have common calls as: (no clue)

dyld

{libsystem_c, libsystem_notify, libdispatch}.dylib: all 10 mallocs have common calls as:

localtime

localtime(...) defined in time.h uses tzset(...) to initialize and return me a struct tm* which I shouldn't free myself because I did not allocate it.

How do I recover these 20,228 bytes which are still reachable?

UPDATE


I am running Mac OS X

6
  • Are you sure you should care about that small leak? And what is your operating system? (If it is Linux or some recent Posix system, you might use dlopen etc... instead of dyld; if it is MacOSX I would not care about leaks inside dyld unless you really dynamically load many thousands of libraries) Apr 11, 2012 at 11:45
  • running Mac OS X, updated the question. Apr 11, 2012 at 11:47
  • I would not care about these leaks... They are apparently not your fault... Why do you want to recover these 20kbytes; the MacOSX kernel will (like any Unix-like kernel) recover that memory when the process exits (either normally thru the _exit syscall or equivalent, or thru a terminating signal eg SIGSEGV or SIGABRT) Apr 11, 2012 at 11:50
  • @Basile - "I would not care about these leaks..." - If a tool like Valgrind is a security gate, then you have to care about them.
    – jww
    Oct 2, 2015 at 16:27
  • But AFAIU this is some bug from MacOSX... Oct 2, 2015 at 16:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.