Opened 8 years ago

Closed 8 years ago

#1007 closed defect (fixed)

AtomicStructures not freed when closed

Reported by: Greg Couch Owned by: pett
Priority: major Milestone: 0.7
Component: Core Version:
Keywords: Cc: chimera-programmers@…
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

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.

Attachments (4)

water.cif (1.8 KB ) - added by Greg Couch 8 years ago.
struct.patch (550 bytes ) - added by Greg Couch 8 years ago.
mmcif_debug.patch (627 bytes ) - added by Greg Couch 8 years ago.
slowleak.py (2.1 KB ) - added by Greg Couch 8 years ago.

Download all attachments as: .zip

Change History (9)

by Greg Couch, 8 years ago

Attachment: water.cif added

by Greg Couch, 8 years ago

Attachment: struct.patch added

by Greg Couch, 8 years ago

Attachment: mmcif_debug.patch added

by Greg Couch, 8 years ago

Attachment: slowleak.py added

comment:1 by Greg Couch, 8 years ago

More information:

All tests were done with "ChimeraX --exit --nogui slowleak.py".

On Linux, there is one unknown "cell" reference to the AtomicStructure left over, and adding "self.triggers = None" in Structure.delete gets rid of it. That problem does not show up on Windows. So all of the rest of the references appear to be from the C++ layer.

comment:2 by pett, 8 years ago

Summary: AtomicStructures do not disappear when closedAtomicStructures not freed when closed

comment:3 by pett, 8 years ago

Component: UnassignedCore
Priority: blockermajor

comment:4 by pett, 8 years ago

Milestone: 0.60.7

comment:5 by pett, 8 years ago

Resolution: fixed
Status: assignedclosed

ctypes handling of non-array python objects was leaky

Note: See TracTickets for help on using tickets.