Hi all.
Although this post concerns a particular compiler I hope the moderators
accept the question as it touches on my general understanding of RAII.
Or maybe lack of such.
I have a program where I allocate a number of data items in containers
of type std::set and std::string.
When I run the program in debug mode (VS2005) the execution monitor
(or whatever the correct term is under VS) complains about 'memory
leaks'.
In the do***entation at
http://msdn.microsoft.com/en-us/library/aa293906.aspx
I find the statement "A memory leak occurs when you allocate memory on
the heap and never deallocate that memory..." It is true that *I* don't
deallocate
that memory, because I expect the destructor of the various containers to
do so when they go out of scope, according to RAII.
So my question is if I am right in that RAII ought to handle things
without
my explicitly mentioning 'delete' in the code (and thus that the compiler
complains unecessarily), or if such issues are handled correctly by the
compiler and this error message points to some fundamental flaw in my
understanding of RAII. Or worse, in my program.
As far as I can tell from the data dump, the problem occurs in a std::set
which contains std::strings,
std::set<std::string> data;
but I haven't been able to pin-point the offending variables with any
certainty.
Rune
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]