ytrembla
10/6/2008 11:13:00 AM
In article <b6517270-cc7a-41e1-9e15-ae0dc1bee0ff@34g2000hsh.googlegroups.com>,
<jacek.dziedzic@gmail.com> wrote:
>On Oct 1, 4:39 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
>> > I'm mostly attempting to track potential memory leaks
>>
>> Aren't there tools to do exactly that, such as valgrind?
>
> Yes, there are three difficulties I'm experiencing with valgrind:
>- not all platforms are supported (Itanium!),
Could you not compile your code on x86 and test it using valgrind?
Seems to work for me although it does make things more difficult.
>- valid code sometimes crashes valgrind's "virtual machine",
> especially hand-tuned, vendor-specific code that does weird
> trickery to squeeze the last cycles out of every pipeline,
Hopefully, this code is only a very small percentage of your code
base. The location where hand tuning was required had been identified
using a profiler (e.g. valgrind callgrind tool). So valgrind is still
very useful to test the other 99% of your codebase.
If you need to run through the whole system and some of the hand
optimised code make valgrind crash, you hopefully could revert back to
the original not-hand-optimised code which you hopefully have
originally written. Hopefully, at some point, you had a version of
the codebase with simple easy switching between the "obvious and
maintainable" code and the "hand optimised unreadable hack" code, so
that you could measure if decreasing the maintainability of your code
base was worth it by giving you any actual perfomrance gain.
>- can only be used for debugging, production code that begins
> to leak after a month of uptime cannot be feasibly "simulated"
> on valgrind.
That is probably because the tests that were run through valgrind
did not cover the code path that is being exercised by the production
code.
Possible solutions:
Expand your unit tests.
Verify your unit tests with a code coverage tool.
Try to figure out what code path is exercised in the deployed system
(through logs, input analysis, head scratching, head banging against a
brick wall, strace...) and then create a targetted test and run the test
through valgrind.