Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.65.2 () OS Version: Ubuntu 20.04.3 LTS This issue is acutally discovered in , but I found that the root cause is from the upstream vscode, so I am submitting the issue here. Steps to Reproduce: a vscode window in the browser. to delete a large file (100MB) deletion takes a long time, or the tab is killed by OOM. The cause I found is that when deleting a file, vscode keeps the file content into memory to support undo operation, only if the file is not too large. But in the code, vscode read the file content unconditionally at first and then discards it if exceeds the size limit. Related issues from code-server

Discussion:
import { WorkspaceFileEditOptions } from 'vs/editor/common/languages'; <del> import { IFileService, FileSystemProviderCapabilities, IFileContent } from 'vs/platform/files/common/files'; </del> <ins> import { IFileService, FileSystemProviderCapabilities, IFileContent, IFileStatWithMetadata } from 'vs/platform/files/common/files'; </ins> import { IProgress } from 'vs/platform/progress/common/progress'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWorkingCopyFileService, IFileOperationUndoRedoInfo, IMoveOperation, ICopyOperation, IDeleteOperation, ICreateOperation, ICreateFileOperation } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';

const undoes: CreateEdit[] = []; for (const edit of this._edits) { <del> if (!await this._fileService.exists(edit.oldUri)) { </del> <ins> let fileStat: IFileStatWithMetadata | undefined; try { fileStat = await this._fileService.resolve(edit.oldUri, { resolveMetadata: true }); } catch (err) { </ins> if (!edit.options.ignoreIfNotExists) { throw new Error(`${edit.oldUri} does not exist and can not be deleted`); }

// read file contents for undo operation. when a file is too large it won't be restored let fileContent: IFileContent | undefined; <del> if (!edit.undoesCreate && !edit.options.folder) { </del> <ins> if (!edit.undoesCreate && !edit.options.folder && !(typeof edit.options.maxSize === 'number' && fileStat.size > edit.options.maxSize)) { </ins> try { fileContent = await this._fileService.readFile(edit.oldUri); } catch (err) { this._logService.critical(err); } } <del> if (!(typeof edit.options.maxSize === 'number' && fileContent && (fileContent?.size > edit.options.maxSize))) { undoes.push(new CreateEdit(edit.oldUri, edit.options, fileContent?.value)); </del> <ins> if (fileContent !== undefined) { undoes.push(new CreateEdit(edit.oldUri, edit.options, fileContent.value)); </ins> } }