imm wrote:
> On 28 Nov 2007, at 20:50, marty moore wrote:
>
>> Didn't realize I was in the presence of a lore master.....
>
> Not me. But there are some around here...
>
>
>> What is the best way to make sure my code is clean?
>
> Valgrind is very useful, but you just need to understand what it is
> telling you. Which isn't easy sometimes. Or most of the time, in my
> experience!
Agreed; valgrind, purify, insure++ and the like are all
very handy tools, but they will tell you about 90% crap
that you really don't want to know about *unless you've
heavily tuned your program down for such purposes)
"Memory leaks" that you should care about are cumulative,
where the program gets bigger and bigger when it shouldn't,
causing it to bloat over time.
Good leak checkers will warn you when allocated pointers
get dropped or overwritten, such that the app has no possible
way to free the memory location because there's no longer a
record of it in any pointer. Not all checkers look for this,
as it's time consuming at runtime.
In some cases it's useful to try to identify blocks of
memory that have accumulated by terminating the program
and seeing what's still allocated, but you often have to
ignore a lot of stuff, as often operating system and c/c++ library
calls leave small amounts of memory allocated (cout/cin)
(or sometimes there are bugs in these calls) as well as
window managers, libraries, etc.
Sometimes it's useful to let the app bloat, then coredump it,
and look at the core to inspect the memory to see what data
has bloated it. Often you can identify the repeating contents
of the core, which is often the largest part of the dump due
to bloat. Then you sniff around in your app to see where that
data is managed, and look for places it's leaking.
I can recommend 'insure++' for finding such things.. I've
used that tool a lot over the years, and although not cheap,
and VERY slow, it's worth it. I've often had to wait 10 minutes
for an app to just start running, which normally takes under a second.
You never have to worry about memory still being allocated
after your program has exited; a common misconception.
If that were the case, we'd be rebooting 50 times a day! ;)
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk