现在很多ai编辑器都是基于开源的vscode改的项目,打开java项目会时会导致内存占用飙升,需要配置优化,剔除多余的内容
按下 Ctrl+Shift+P → 输入 Preferences: Open User Settings (JSON),添加以下内容:
java日常开发版
json{
"app": {
"configGeneralDisplayLanguage": "zh-cn",
"configGeneralAiResponseLanguage": "zh-cn",
"configGeneralImportSettings": "VS Code",
"configCompletionEnableCompletion": true,
"configCompletionAutoTriggerLength": "medium",
"configCompletionEnableNES": true,
"configCompletionDisabledLanguages": [],
"configCompletionTriggerInComment": true,
"configCompletionAutoImport": true,
"configChatWebToolsMode": "Ask every time",
"configChatAskModeUseTools": true,
"configChatEditFileTool": false,
"configChatTerminalRunMode": "autoReview",
"configChatCommandDenyList": "rm,mv,sudo,wget,curl,chown",
"configChatCommandAllowlist": "",
"configChatAutoRunMcpTools": true,
"configChatMethodQuickOperation": false,
"configChatShowSelectionToolbar": true,
"configQuestEnable": true,
"configMemoryAutoGenerate": false,
"configAdvancedAutoUpdate": true,
"configAdvancedProxyMode": "system",
"configAdvancedProxyURL": "",
"configSecurityScanL1StaticCheck": false,
"configSecurityScanL2LightweightScan": false,
"configSecurityScanL3DeepScan": false,
"configSecurityScanSettingsPageVisited": true,
"configIntegrationsAppWindowSnapshotShortcut": "Disabled",
"configIntegrationsGoalMaxTurns": 20,
"configIntegrationsBrowserType": "native",
"configIntegrationsBrowserRunMode": "Ask every time",
"configIntegrationsBrowserToolsRunMode": "Auto-run",
"configIntegrationsPlanModeRunConfig": "Ask every time",
"configIntegrationsComputerUseRunMode": "Ask every time",
"configIntegrationsQuestBrowserType": "native",
"configIntegrationsQuestBrowserRunMode": "Auto-run",
"configIntegrationsQuestBrowserToolsRunMode": "Auto-run",
"configIntegrationsQuestPlanModeRunConfig": "Auto-run",
"configIntegrationsQuestComputerUseRunMode": "Auto-run",
"configVoiceInputVoiceprintEnabled": true,
"configVoiceInputAudioDeviceId": "",
"configVoiceInputDjiMicAutoSendEnabled": true,
"configVoiceInputHotwords": [],
"configLiveVoiceVoice": "default",
"configLiveVoiceScreenContextEnabled": true,
"configLiveVoiceVoiceprintEnabled": false,
"configMobileAllowRemoteControl": false,
"configMobileKeepAwake": false
},
"workbench.colorTheme": "Solarized Light+",
// ========================================================================
// Java 内存优化 —— 通用开发版
// 保留:源码/jar 跳转、补全、格式化、单测、调试
// 改完执行命令面板:Java: Restart Language Server
// ========================================================================
// ---------- 1. JVM(对内存影响最大的一档)----------
"java.jdt.ls.vmargs": "-XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xms256m -Xmx1536m -XX:MaxMetaspaceSize=384m -XX:ReservedCodeCacheSize=192m -Dsun.zip.disableMemoryMapping=true -Dfile.encoding=UTF-8",
// ---------- 2. 工程模型(Maven 导入必须开,否则依赖无法解析、跳转失效)----------
"java.import.maven.enabled": true,
"java.import.gradle.enabled": false,
"java.autobuild.enabled": false,
"java.maxConcurrentBuilds": 1,
"java.configuration.updateBuildConfiguration": "interactive",
"java.maven.downloadSources": false,
"java.eclipse.downloadSources": false,
"java.jdt.ls.androidSupport.enabled": false,
"java.project.resourceFilters": [
"node_modules", ".git", ".idea", "target", "build", "out", "dist"
],
"java.import.exclusions": [
"**/node_modules/**", "**/.metadata/**", "**/target/**", "**/build/**",
"**/out/**", "**/dist/**", "**/archetype-resources/**", "**/META-INF/maven/**"
],
// ---------- 3. 附属 LSP 能力(不影响跳转/补全/格式化)----------
"editor.codeLens": true,
"java.referencesCodeLens.enabled": false,
"java.implementationsCodeLens.enabled": false,
"editor.inlayHints.enabled": false,
"java.signatureHelp.enabled": false,
"java.selectionRange.enabled": false,
"java.format.enabled": true,
"java.format.onType.enabled": false,
// ---------- 4. 编辑器渲染 ----------
"workbench.reduceMotion": "reduce",
"editor.minimap.enabled": false,
"editor.stickyScroll.enabled": false,
"breadcrumbs.enabled": false,
"editor.guides.indentation": false,
"editor.suggest.showWords": false,
"files.maxMemoryForLargeFilesMB": 1024,
// ---------- 5. 文件监听 / 搜索 ----------
"search.followSymlinks": false,
"files.watcherExclude": {
"**/target/**": true,
"**/build/**": true,
"**/out/**": true,
"**/node_modules/**": true,
"**/dist/**": true,
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/.idea/**": true,
"**/*.class": true,
"**/*.jar": true,
"**/*.log": true
},
"search.exclude": {
"**/target/**": true,
"**/build/**": true,
"**/out/**": true,
"**/node_modules/**": true,
"**/dist/**": true,
"**/.git/**": true
},
"files.exclude": {
"**/target/**": true,
"**/build/**": true,
"**/out/**": true,
"**/node_modules/**": true,
"**/dist/**": true
},
// ---------- 6. 其他常驻进程 ----------
"git.autofetch": false,
"git.autorefresh": false,
"telemetry.telemetryLevel": "off",
"terminal.integrated.scrollback": 1000
}
极致优化版
json{
"app": {
"configGeneralDisplayLanguage": "zh-cn",
"configGeneralAiResponseLanguage": "zh-cn",
"configGeneralImportSettings": "VS Code",
"configCompletionEnableCompletion": true,
"configCompletionAutoTriggerLength": "medium",
"configCompletionEnableNES": false,
"configCompletionDisabledLanguages": ["java"],
"configCompletionTriggerInComment": true,
"configCompletionAutoImport": true,
"configChatWebToolsMode": "Ask every time",
"configChatAskModeUseTools": true,
"configChatEditFileTool": false,
"configChatTerminalRunMode": "autoReview",
"configChatCommandDenyList": "rm,mv,sudo,wget,curl,chown",
"configChatCommandAllowlist": "",
"configChatAutoRunMcpTools": true,
"configChatMethodQuickOperation": false,
"configChatShowSelectionToolbar": true,
"configQuestEnable": true,
"configMemoryAutoGenerate": false,
"configAdvancedAutoUpdate": true,
"configAdvancedProxyMode": "system",
"configAdvancedProxyURL": "",
"configSecurityScanL1StaticCheck": false,
"configSecurityScanL2LightweightScan": false,
"configSecurityScanL3DeepScan": false,
"configSecurityScanSettingsPageVisited": true,
"configIntegrationsAppWindowSnapshotShortcut": "Disabled",
"configIntegrationsGoalMaxTurns": 20,
"configIntegrationsBrowserType": "native",
"configIntegrationsBrowserRunMode": "Ask every time",
"configIntegrationsBrowserToolsRunMode": "Auto-run",
"configIntegrationsPlanModeRunConfig": "Ask every time",
"configIntegrationsComputerUseRunMode": "Ask every time",
"configIntegrationsQuestBrowserType": "native",
"configIntegrationsQuestBrowserRunMode": "Auto-run",
"configIntegrationsQuestBrowserToolsRunMode": "Auto-run",
"configIntegrationsQuestPlanModeRunConfig": "Auto-run",
"configIntegrationsQuestComputerUseRunMode": "Auto-run",
"configVoiceInputVoiceprintEnabled": true,
"configVoiceInputAudioDeviceId": "",
"configVoiceInputDjiMicAutoSendEnabled": true,
"configVoiceInputHotwords": [],
"configLiveVoiceVoice": "default",
"configLiveVoiceScreenContextEnabled": true,
"configLiveVoiceVoiceprintEnabled": false,
"configMobileAllowRemoteControl": false,
"configMobileKeepAwake": false
},
"workbench.colorTheme": "Solarized Light+",
// ========================================================================
// Java 内存优化 —— 极致只读浏览版
// 保留:方法/类跳转、查找引用、悬停文档、大纲
// 关闭:补全、签名提示、格式化、重命名重构、括号着色
// 改完执行命令面板:Java: Restart Language Server
// ========================================================================
// ---------- 1. JVM(小堆 + SerialGC + 只开 C1 编译)----------
"java.jdt.ls.vmargs": "-XX:+UseSerialGC -XX:TieredStopAtLevel=1 -Xms128m -Xmx768m -XX:MaxMetaspaceSize=256m -XX:ReservedCodeCacheSize=128m -Dsun.zip.disableMemoryMapping=true -Dfile.encoding=UTF-8",
// ---------- 2. 工程模型(保留 Maven 导入以维持依赖跳转)----------
"java.import.maven.enabled": true,
"java.import.gradle.enabled": false,
"java.autobuild.enabled": false,
"java.maxConcurrentBuilds": 1,
"java.configuration.updateBuildConfiguration": "disabled",
"java.maven.downloadSources": false,
"java.eclipse.downloadSources": false,
"java.configuration.detectJdksAtStart": false,
"java.jdt.ls.androidSupport.enabled": false,
"java.project.resourceFilters": [
"node_modules", ".git", ".idea", "target", "build", "out", "dist"
],
"java.import.exclusions": [
"**/node_modules/**", "**/.metadata/**", "**/target/**", "**/build/**",
"**/out/**", "**/dist/**", "**/archetype-resources/**", "**/META-INF/maven/**"
],
// ---------- 3. 只留"读"能力 ----------
"java.hover.enabled": true,
"java.completion.enabled": false,
"java.signatureHelp.enabled": false,
"java.selectionRange.enabled": false,
"java.rename.enabled": false,
"java.format.enabled": false,
"java.format.onType.enabled": false,
"java.saveActions.organizeImports": false,
"editor.codeLens": false,
"java.referencesCodeLens.enabled": false,
"java.implementationsCodeLens.enabled": false,
"editor.inlayHints.enabled": false,
"editor.parameterHints.enabled": false,
"editor.quickSuggestions": false,
"editor.suggestOnTriggerCharacters": false,
"editor.suggest.showWords": false,
// ---------- 4. 渲染 + 限制同时打开的编辑器数 ----------
"workbench.editor.limit.enabled": true,
"workbench.editor.limit.value": 5,
"workbench.editor.limit.perEditorGroup": true,
"workbench.reduceMotion": "reduce",
"editor.minimap.enabled": false,
"editor.bracketPairColorization.enabled": false,
"editor.guides.bracketPairs": false,
"editor.guides.indentation": false,
"editor.stickyScroll.enabled": false,
"breadcrumbs.enabled": false,
"files.maxMemoryForLargeFilesMB": 512,
// ---------- 5. 文件监听 / 搜索 ----------
"search.followSymlinks": false,
"files.watcherExclude": {
"**/target/**": true,
"**/build/**": true,
"**/out/**": true,
"**/node_modules/**": true,
"**/dist/**": true,
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/.idea/**": true,
"**/*.class": true,
"**/*.jar": true,
"**/*.log": true
},
"search.exclude": {
"**/target/**": true,
"**/build/**": true,
"**/out/**": true,
"**/node_modules/**": true,
"**/dist/**": true,
"**/.git/**": true
},
"files.exclude": {
"**/target/**": true,
"**/build/**": true,
"**/out/**": true,
"**/node_modules/**": true,
"**/dist/**": true
},
// ---------- 6. 其他常驻进程 ----------
"git.autofetch": false,
"git.autorefresh": false,
"telemetry.telemetryLevel": "off",
"terminal.integrated.scrollback": 200
}
本文作者:Weee
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!