• Jim Fulton's avatar
    Changed the destructor protocol to prevent "refcount leakage". The · 1c675814
    Jim Fulton authored
    reference counts of extension classes are increased when instances are
    created.  Prior to this change, the class ref counts were only
    decreased by subclass destructors.  Base class destructors followed
    the Python protocol and didn't DECREF thier classes (types).  (Python
    type ref counts have nothing to do with instance life times, since
    Python types are static, unlike extension classes, which may be
    dynamic.)
    
    This caused the ref counts of instantiatable base classes to grow,
    which looked like a memory leak.
    
    Now, the destructor protocol calls for base class destructors to
    DECREF the class in addition to deallocating the object.  The subclass
    destructor *only* DECREFs the class if it has to deallocate the object
    because there was no base class destructor.
    
    This also fixed an logic ordering problem that caused some dynamically
    created classes to be destroyed while they were still needed.
    1c675814
ExtensionClass.c 86.8 KB