Neil Cerutti wrote:[color=blue]
> On 2005-12-01,
roberts.noah@gmail.com <roberts.noah@gmail.com>
> wrote:[color=green]
> > Yesturday I chased down a memory leak being reported by our
> > leak detection library. It lead me to question this line of
> > code:
> >
> > str_instance = std::string();[/color]
>
> There should be no resource leak here.
>
> Perhaps you've simply covered up the symptom of some other bug.
> Could the representation of str_instance be getting fouled up
> somewhere else?[/color]
I don't believe so. I do pass a const reference of the string outside
the class but nobody tries to alter it and there's no const_cast trying
to get rid of its constness. There is only the one member function
where anything is done to that string, it is a cache that holds a
string value of some complex calculations that are meant to be drawn on
the screen.
Perhapse the implementation is doing some sort of fancy memory
management that tries to make string allocation faster. Maybe that
management is leaving pointers around and doesn't get told to delete
them until after the memory leak detection occurs. I have to admit I
don't really know how this detection library is supposed to work and
there are other false positives that we are aware of and ignore.
It's probably a non-issue.