diff --git a/src/core/tools/applyDiffTool.ts b/src/core/tools/applyDiffTool.ts index 2c637bc219..4730f6f52a 100644 --- a/src/core/tools/applyDiffTool.ts +++ b/src/core/tools/applyDiffTool.ts @@ -87,7 +87,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( @@ -99,6 +99,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