[C++-sig] Memory Leaks In VS.NET 2003 With BOOST_PYTHON_MODULE
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Sat Oct 8 01:29:09 CEST 2005
--- Matt <mjkeyes at sbcglobal.net> wrote:
> handle<> hInitPtr(PyImport_ImportModule( "Python.SnakeMUD" ));
I think this is correct code, and I know for sure the handle<>
constructor doesn't introduce memory leaks. But I don't know what
"Python.SnakeMUD" is. What happens if you import "sys" instead?
> However, when I uncomment even just the first line (the hInitPtr),
> I get 17 leaks.
How do you measure memory leaks?
E.g. dynamically loading modules is irreversible in C Python. I could imagine
some associated allocation overhead that is not de-allocated until the process
finishes.
If I suspect a leak somewhere my usual response is to call the corresponding
functions repeatedly in an infinite loop and manually monitor the total
allocation of the process (e.g. "top" under Linux or the Task Manager under
Windows). With this method even tiny leaks usually show up very quickly on the
radar, while one-time static allocations connected to imports or other static
initializers don't create any visible noise.
Cheers,
Ralf
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
More information about the Cplusplus-sig
mailing list