[C++-sig] memory leaks using the "manage_new_object"return policy...

Kevin Jones investtcartier at yahoo.com
Thu Sep 14 23:13:55 CEST 2006


Roman Yakovenko <roman.yakovenko <at> gmail.com> writes:

> 
> On 9/14/06, Kevin Jones <investtcartier <at> yahoo.com> wrote:
> > Hi,
> >
> > I am using the manage_new_object return policy to wrap
> > "newed" C++ object in an effort to conserve memory.
> >
> > Even though I am deleting the returned object in
> > Python and invoking the Python garbage collector I
> > still have a leak. This is a long-running systems
> > adminstration app the read the contents of a very
> > large database.
> >
> > Any suggestions on how to make manage_new_object
> > behave correctly?
> 
> May be I can help. I am just going through "same" process. It is up to
> you to prove
> that boost.python does not free the memory. So if you create small test case
> ( one cpp, one Python script, Jamfile ) that reproduce the error, I
> think you will get the answer\solution to your problem pretty quick.
> 
Roman,

One direct solution is the use of Purify which I get access next week. Another
consideration, is that when I changed the return policy to "return_by_value" the
same leak behavior was exhibited (N.B. - I call the python garbage collector
explcitly for each object).  Presumably, boost.python would delete an object
that it was converting to python as it would definitely be garbage otherwise.

I will work on the small test case.

Kevin





More information about the Cplusplus-sig mailing list