Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Visual Studio 2...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 9817 of 9984
Post > Topic >>

Visual Studio 2005 complains about memory leaks

by Rune Allnor <allnor@[EMAIL PROTECTED] > Jul 22, 2008 at 03:31 PM

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! ]
 




 4 Posts in Topic:
Visual Studio 2005 complains about memory leaks
Rune Allnor <allnor@[E  2008-07-22 15:31:03 
Re: Visual Studio 2005 complains about memory leaks
Rune Allnor <allnor@[E  2008-07-22 21:04:57 
Re: Visual Studio 2005 complains about memory leaks
marlow.andrew@[EMAIL PROT  2008-07-24 05:58:20 
Re: Visual Studio 2005 complains about memory leaks
"Martin T." <  2008-07-28 02:58:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 8:41:12 CDT 2008.