releasing memory in apply diff (#4193)

This commit is contained in:
xyOz 2025-06-02 04:08:46 +01:00 committed by GitHub
parent d079cb11ff
commit eb9c4aa03d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,7 +86,7 @@ export async function applyDiffTool(
return
}
const originalContent = await fs.readFile(absolutePath, "utf-8")
let originalContent: string | null = await fs.readFile(absolutePath, "utf-8")
// Apply the diff to the original content
const diffResult = (await cline.diffStrategy?.applyDiff(
@ -98,6 +98,9 @@ export async function applyDiffTool(
error: "No diff strategy available",
}
// Release the original content from memory as it's no longer needed
originalContent = null
if (!diffResult.success) {
cline.consecutiveMistakeCount++
const currentCount = (cline.consecutiveMistakeCountForApplyDiff.get(relPath) || 0) + 1