mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +00:00
fix: 修复长时间运行会话的内存泄漏问题
/clear 时释放 STATE 中保存的大块数据(API 请求/分类器请求/模型统计), 全屏模式增加 500 条消息上限防止无限增长,修复 progress 消息去重逻辑 避免交错消息导致重复累积(观察到 13k+ 条目/1GB+ 堆)。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,10 @@ import {
|
||||
getOriginalCwd,
|
||||
getSessionId,
|
||||
regenerateSessionId,
|
||||
resetCostState,
|
||||
setLastAPIRequest,
|
||||
setLastAPIRequestMessages,
|
||||
setLastClassifierRequests,
|
||||
} from '../../bootstrap/state.js'
|
||||
import type { SDKStatusMessage } from '../../entrypoints/sdk/coreTypes.js'
|
||||
import {
|
||||
@@ -144,6 +148,14 @@ export async function clearConversation({
|
||||
// tracking) is retained so those agents keep functioning.
|
||||
clearSessionCaches(preservedAgentIds)
|
||||
|
||||
// Clear large STATE-held data that outlives the message array.
|
||||
// lastAPIRequestMessages can hold the full post-compaction conversation
|
||||
// (hundreds of KB–MB) for /share; resetCostState clears modelUsage.
|
||||
setLastAPIRequest(null)
|
||||
setLastAPIRequestMessages(null)
|
||||
setLastClassifierRequests(null)
|
||||
resetCostState()
|
||||
|
||||
setCwd(getOriginalCwd())
|
||||
readFileState.clear()
|
||||
discoveredSkillNames?.clear()
|
||||
|
||||
Reference in New Issue
Block a user