How to resolve dyld and localtime leaks when profiling a project?
Asked Answered
N

0

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

Nolde answered 11/4, 2012 at 11:40 Comment(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)Blowhole
running Mac OS X, updated the question.Nolde
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)Blowhole
@Basile - "I would not care about these leaks..." - If a tool like Valgrind is a security gate, then you have to care about them.Coolant
But AFAIU this is some bug from MacOSX...Blowhole
Also see Add localtime() to internal ignore list for OS X on the Valgrind Developer's mailing list.Coolant

© 2022 - 2024 — McMap. All rights reserved.