[C++-sig] memory leaks using the

Stefan Seefeld seefeld at sympatico.ca
Thu Sep 14 23:22:23 CEST 2006


Kevin Jones wrote:
> Stefan Seefeld <seefeld <at> sympatico.ca> writes:
> 
>> Kevin Jones 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.
>> The obvious question: Are you sure your C++ objects are
>> not deleted, while the python (wrapper) objects are ?
>>
>> Regards,
>> 		Stefan
>>
> 
> Stefan,
> 
> In the python code I do the following:
> 
>     del x
>     gc.collect()
>     msvcrt.heapmin()    
> 
> I'm not sure what I could do beyond the above.

Insert print statements into the destructors of both,
the C++ as well as the python objects and see whether
they get triggered in pairs or not.

And only if you can prove that the python object got in
fact deleted but not the C++ object it is supposed to own
you should claim it is the manage_new_object that is doing
something wrong. (minimal test case etc....)

Regards,
		Stefan





More information about the Cplusplus-sig mailing list