|
Boost Users : |
From: Seweryn Habdank-Wojewódzki (shw_at_[hidden])
Date: 2007-05-28 10:25:42
Hi
> 'possibly lost' seems less than conclusive that there's actually a leak.
Yes I know, but sometimes it is possible to eliminate them completely, even
if "variable" exists until the end of the program.
Especially If the program is written in C++. In C++ where you have RAII, and
you can control static initialisation and destruction there is an opportunity
to release all resources.
Some months ago I have developed simple logger (http://cxxtl.sf.net) and there
I had a problem that resources of logger HAVE TO stay in memory until the
last usage of logger is finished even if it is in statically allocated class
destructors.
Logger produce something like below.
foo.cpp [7] : Creation of the foo object.
main.cpp [30] : Trivial logger in main().
...
main.cpp [12] : atexit()->finalize()->EXIT_SUCCESS
foo.cpp [12] : Destruction of the foo object.
Logger observe atexit function.
Logger even can observe final destructions.
And valgrind do not report any leak:
==24722== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 7 from 1)
==24722== malloc/free: in use at exit: 0 bytes in 0 blocks.
==24722== malloc/free: 8 allocs, 8 frees, 8,870 bytes allocated.
==24722== For counts of detected errors, rerun with: -v
==24722== All heap blocks were freed -- no leaks are possible.
So sometimes it is possible to eliminate possible leaks (cause they are at the
end of the program). If in your case it is possible to eliminate this from
the code I willbe grateful for that, if not, I understand, because In my
logger I had similar problem.
Best regards.
-- |\/\/| Seweryn Habdank-Wojewódzki \/\/
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net