[Twisted-Python] help with refcounts and memleaks

Jesus Cea jcea at argo.es
Mon Dec 26 21:28:30 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Wow, Andrea Arcangeli, of Linux Kernel fame. What an honor :).

> +		import gc
> +		gc.collect()

Haha. I was just writing you about manual garbage collector invocations.

Manual collections can be costly, nevertheless. Since the manual
collector is only needed to free cyclic references, I guess that Twisted
people would rather prefer a patch to break cyclic references in Twisted
code. For example, using "__del__" methods or "weakref".

You can easily see what objects and references keep the cycles alive
using "gc.garbage" and "gc.get_referrers()". Usually a single
"a.value=None" can do miracles :-). Weakref can be very very helpful, also.

http://docs.python.org/lib/module-gc.html
http://docs.python.org/lib/module-weakref.html

Merry Christmas and happy 2006, by the way.

- --
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea at argo.es http://www.argo.es/~jcea/ _/_/    _/_/  _/_/    _/_/  _/_/
                                      _/_/    _/_/          _/_/_/_/_/
PGP Key Available at KeyServ   _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBQ7Cmzplgi5GaxT1NAQJndAP/YQNK/wHcBWIBfybJEeMyyaCJ+nxNsOXo
XYZ/L0znLwnUY2enpwQ9GWDb1N1JlSRGyBs19EVXsu1kl9XuCxKjO+Qc2wuZE8La
kspNJu9ZEHTVn8hNhgoZkFsKmed8g2zvP8HmlFD1ZEdXJ3+nuzmf2AjcsBHUkFl8
Aqe1+xrIp+Q=
=Cobp
-----END PGP SIGNATURE-----




More information about the Twisted-Python mailing list