﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	notify_on_close	platform	project
1007	AtomicStructures not freed when closed	Greg Couch	Eric Pettersen	"The attached program, slowleak.py, shows what objects stick around after the structure is closed.  In particular, the structure sticks around.  3 scenarios were explored, a structure with just waters (attached waters.cif), one with just a few nucleotides (3rec), and a large protein (2hmg).

After making the attached patch to atomic/structure.py to clear the list of trigger handlers when deleted, the waters test works, but the others still fail.

Here is a table of the references counts for the structure, (1) after returning from C++ and creating the AtomicStructure object, (2) after returning from commands.open(), and (3) after returning from commands.close(), garbage collecting, and checking what remains:

{{{
          waters  3rec  2hmg
after C++     8     8     8
after open   12    14    25
after close   0     3    14
}}}

The reference counts include the reference as an argument to sys.getrefcount and of the object in the scope that sys.getrefcount was called in.

The structure patch eliminates a circular reference path, the lambda with the bound method self._ses_call hold a reference to the structure and _ses_handlers in the structure keep track of them.  It is unclear why this is too complicated for Python's garbage collector in the water's case.  So I'll commit that change.

Not sure where to look next."	defect	closed	major	0.7	Core		fixed		chimera-programmers@…				all	ChimeraX
