fix(runtime): shutdown hook holds the runtime weakly #57

Merged
KofTwentyTwo merged 1 commits from fix/shutdown-hook-weak-runtime into develop 2026-10-15 20:57:50 +00:00
KofTwentyTwo commented 2026-10-15 20:53:58 +00:00 (Migrated from github.com)

Every AssistantRuntime registered a JVM shutdown hook that held the runtime, and through it the whole QInstance, until the JVM exited. A host test suite that builds an instance per test leaked every instance.

kof22's Website-Backend suite now runs out of heap in CI. I found the leak with a reachability search: after GC, every built instance stayed reachable through ApplicationShutdownHooks -> assistant-shutdown-* -> AssistantRuntime.qInstance, and that was the only path left.

The hook now holds the runtime through a WeakReference; production shutdown is unchanged.

🤖 Generated with Claude Code

Every `AssistantRuntime` registered a JVM shutdown hook that held the runtime, and through it the whole QInstance, until the JVM exited. A host test suite that builds an instance per test leaked every instance. kof22's Website-Backend suite now runs out of heap in CI. I found the leak with a reachability search: after GC, every built instance stayed reachable through `ApplicationShutdownHooks -> assistant-shutdown-* -> AssistantRuntime.qInstance`, and that was the only path left. The hook now holds the runtime through a `WeakReference`; production shutdown is unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.