[C++-sig] Memory Leaks In VS.NET 2003 With BOOST_PYTHON_MODULE
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Thu Oct 13 17:59:14 CEST 2005
--- mjkeyes at sbcglobal.net wrote:
> Hey again, I'm back.
Hi Arnold! :)
> Here is some pseudo-code of what I'm doing:
Could you please turn this into a self-contained reproducer? Please explain
exactly how you compile and link. Note that you have to be very careful to not
mix debug and release builds under Windows.
> class A
> void SetString(const std::string &sVal)
> m_sString = sVal; <--- Memory leak
I am doing things like this all the time and I am sure it doesn't leak for me.
> void DoStuff()
> static const std::string msc_sString;
Probably a side issue: do you really want "static" here?
> class B
> object CreateClassA()
> return object(new CreateClassA()); <---- memory leak
What is this? Does this even compile?
In any event, of course you get a memory leak if you use new like that.
Ideally, you don't have any "unencapsulated" new in your code. Always use
boost::shared_ptr<T>(new T) or std::auto_ptr<>(new T) or any other smart
> Any suggestions? I'm not getting any errors from the interpreter.
We need a complete reproducer.
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
More information about the Cplusplus-sig