[pyar] Problemas de memory leak

Lucas rollbak en gmail.com
Mar Oct 5 14:47:43 ART 2010


On Tue, Oct 5, 2010 at 2:33 PM, Lucas <rollbak en gmail.com> wrote:

> On Tue, Oct 5, 2010 at 2:14 PM, Roberto Alsina <ralsina en netmanagers.com.ar
> > wrote:
>
>> Tengo un reporte de bug en rst2pdf de que pierde memoria. Acá esta:
>>
>> http://code.google.com/p/rst2pdf/issues/detail?id=343
>>
>> Pero lo basico es esto:
>>
>> ------------------
>>
>>    class default_object(dict):
>>        ''' By default, RSON objects are dictionaries that
>>            allow attribute access to their existing contents.
>>        '''
>>        def __init__(self):
>>            self.__dict__ = self
>>
>> The problem is that since dict is implemented in C, if there's a circular
>> reference to itself, the object would not get garbage collected.
>>
>> ------------------
>>
>> Que me sugieren?
>> _______________________________________________
>> pyar mailing list pyar en python.org.ar
>> http://listas.python.org.ar/listinfo/pyar
>>
>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>
>
>
>
> No se pueden usar weak references para evitar eso?
>
> --
> Lucas
>


class default_object(dict):
       def __init__(self):
           self.__dict__ = weakref.ref(self)()

Esto funciona igual que la implementacion original y deja al GC liberar el
objeto cuando no tiene mas referencias (sin tener en cuenta las referencias
weak).

-- 
Lucas
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20101005/b0878ba2/attachment.html>


More information about the pyar mailing list