fix: memory cycle in diverts - #23
brentjanderson wants to merge 1 commit into
Conversation
There is an Rc<T> cycle between a Container, a Divert, back to a Container. This reliably produces a memory leak when running multiple stories in parallel (memory_leak_test covers this case). By caching potential targets and using Weak<T> to break the cycle, we avoid this memory leak case. This shouldn't change the performance profile of a running story, as target references are already lazily loaded. We are just moving from the Divert struct to a shared cache with weak references.
69e07cd to
6260147
Compare
|
Thank you, @brentjanderson, for identifying this real reference-cycle leak and for proposing the correct core solution: caching the target container through I am closing this PR because it can no longer be merged cleanly in its current form:
The replacement PR, #32, ports the fix to the current tree, satisfies the current lint rules, and replaces the allocator-based stress test with a focused ownership test that constructs the exact Thanks again for the valuable report and original fix. |
There is an
Rc<T>cycle between a Container, a Divert, back to a Container. This reliably produces a memory leak when running multiple stories in sequence or parallel (memory_leak_test helps verify this).By caching potential targets and using
Weak<T>to break the cycle, we avoid this memory leak case.This shouldn't change the performance profile of a running story, as target references are already lazily loaded. We are just moving from the Divert struct to a shared cache with weak references.