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
Hoist from_array_interface wrapper class to module scope
`from_array_interface` defined its `Array` wrapper class inside the
function body, so a fresh class object was created on every call. Class
objects are self-referential (via `__dict__`, `__mro__` and their property
descriptors), so each one forms a reference cycle that reference counting
alone cannot reclaim. Because `from_array_interface` runs on every
prediction, this produced cyclic garbage on every request; long-running
inference services that disable the cyclic GC (a common latency
optimization) saw unbounded memory growth as these cycles -- and the
native buffers they pin -- accumulated.
Move the wrapper to module scope as `_ArrayInterfaceProxy` so it is
created once at import. The per-call instance is not part of a cycle (it
references the module-level class, which does not reference it back), so it
is freed immediately by reference counting with no GC needed. Behavior is
unchanged.
Co-authored-by: Cursor <cursoragent@cursor.com>
0 commit comments