[Patches] GC with support for PyMethodObjects

Neil Schemenauer nascheme@enme.ucalgary.ca
Mon, 5 Jun 2000 19:22:34 -0600


I have added GC support for PyMethodObjects.  As always, the
latest patch (lightly tested) is at:

    http://www.enme.ucalgary.ca/~nascheme/python/gc-cycle.diff

It is fairly easy to create a reference cycle using method
objects:

    >>> class A:
    ...     def __init__(self):
    ...         self.init = self.__init__
    ... 
    >>> A()
    <__main__.A instance at 81cb66c>
    >>> 1
    1
    >>> import gc
    >>> gc.collect()
    gc: collectable <dictionary 0x81bef14>
    gc: collectable <A instance at 81cb66c>
    gc: collectable <instance method 0x81bbecc>
    3
    
I was suprised when this change revealed that Jeremy's compiler
leaks memory.  This can easily be demonstrated by putting the
compile.py main() function in a "while 1" loop.  Without GC the
process size keeps growing.  I wonder how many other programs
contain similar leaks.

    Neil

-- 
fortune: Segmentation fault (core dumped)