Python mem leaks?

tomas.bouda at systinet.com tomas.bouda at systinet.com
Wed Dec 3 12:53:38 EST 2003


  Hi,
you're right, my objects were held in Python backtrace.
That was what I thought but I was a bit confused 'cause PyErr_Clear() didn't 
clear the backtrace, just set the exception flag. 

Now, I'm calling { PyErr_SetNone(PyExc_Exception); PyErr_Clear(); } which 
clears memory. Probably a hack but works fine. 

Thanks a lot for your help. 

Best Regards,
Tobbi 


A.T.Hofkamp writes: 

> In comp.lang.python, you wrote:
>> 
>> def do_smth2(panel):
>>    raise Exception()  
>> 
>> Calling do_smth1() will cause returning of Py_None, the PyCObject <panel> is 
>> freed and the C finalizer (mentioned in no.2) is called.
>> Calling do_smth2() will case returning NULL a <panel> is not freed nor 
>> finalizer is called. At this point I get a leak! 
> 
> What happens if you handle the exception? 
> 
> My guess is that in the stack backtrace, there is a reference to panel.
> Since handling the exception may mean printing the stack, Python still
> needs the object.
> If you handle the exception, I would expect Python to release the stack
> trace information, and thus the object. 
> 
> 
> Albert
> -- 
> Unlike popular belief, the .doc format is not an open publically available format. 
> 
 






More information about the Python-list mailing list