You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Release source-rebinding closure after successful trajectory tokenization #1010
Successful trajectory tokenization retains completed source graphs until cyclic GC, even after the caller drops both the input and returned result. This predates #977: it reproduces on 6f0ca471 and maintained main 333b8bdd.
_serialization._rebind_history_sources creates a recursive local visit function. Its closure contains both a reference to visit itself and the canonical exchange list/identity map. Dropping the returned tokenized object therefore leaves a library-created cycle that still owns the exchanges and request data.
The public CPU reproduction distinguishes intentional caller ownership from retention:
History-only tokenization releases inputs immediately after caller/result deletion.
Trajectory, trace and group tokenization retain the inputs until gc.collect().
A finite burst of 32 successful trajectory calls retains all 32 otherwise-unreferenced inputs with GC disabled; collection releases all 32.
The live retained visitor closure contains its own function object and the matching canonical exchange. The test harness returns only weak references after the call.
This is deferred reclamation, not evidence of a permanent leak with GC enabled. It can increase memory pressure between collections. It is separate from the sticky-exception retention correction in #977 and is not a qualification gate.
Minimal repository-local reproduction (using an existing public test fixture):
Activity