Commit 551bd8b
fix(sdk): unregister atexit handler in LocalConversation.close()
LocalConversation.__init__ registers atexit.register(self.close), creating
a permanent reference from the atexit handler list to the conversation
object. When close() is called the registration is never removed, so the
entire conversation object graph (agent, LLMs, event log, file store, all
events) is pinned in memory forever.
Add atexit.unregister(self.close) at the top of close() so conversations
become fully GC-able after cleanup. On a long-running server processing
hundreds of conversations this prevents monotonic memory growth.
Closes #3136
Co-authored-by: openhands <openhands@all-hands.dev>1 parent e529761 commit 551bd8b
2 files changed
Lines changed: 48 additions & 0 deletions
File tree
- openhands-sdk/openhands/sdk/conversation/impl
- tests/sdk/conversation
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
977 | 977 | | |
978 | 978 | | |
979 | 979 | | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
980 | 983 | | |
981 | 984 | | |
982 | 985 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
0 commit comments