我正在使用 Visual Studio 代码。我的机器遇到性能问题。我去任务管理器看到有几个Code.exe
的实例在进程选项卡中,即使我的 PC 上只有一个运行/事件的 Visual Studio Code 窗口。
我可以看到总共有八个 Code.exe
的实例。 .尽管如此,我可以看到所有八个实例都占用了几 KB 到最大 55 MB 的 RAM 内存。所以有一件事可以肯定,这几个进程并没有占用太多内存,但它们的计数仍然让我绊了一跤。我了解到一个 Visual Studio Code 窗口应该映射到一个 Code.exe
过程。
我还有一个观察。我打开了另一个 Visual Studio Code 的新窗口,看到了 Code.exe
的计数。这次增加了两个而不是一个。总计 Code.exe
当当前共有 2 个 Visual Studio Code 窗口处于事件状态时,进程计数现在单独变为 10。我不确定这里发生了什么。有人可以帮助我了解这是否是内部实现 Visual Studio Code 的正确行为吗?
最佳答案
此行为是设计使然,并记录在 Github 问题 #5856 的评论中。 , #8006和 #20856
链接中提到的评论摘要
This behavior is a consequence of both how vscode was designed and the fact that it's build on Chromium/Electron. The number of processes should not really matter from an end user perspective, it's the amount of work each process does and the communication between them that are important.
By design, the UI framework we use is multi process by itself and then we have 1 process for extensions (per window), one process for file watching (per window) and 1 process for search. We also have 1 shared process for updates.
使用 Process Explorer 之类的工具,您可以获得有关流程的更多详细信息。
只有一个进程
code.exe
将父级设为 explorer.exe
这表示产生其他子进程的主进程。以下是 Main code.exe
的截图使用工具 显示属性进程浏览器 .此外,快速浏览每个子项的命令行参数
code.exe
流程将提供关于每个流程应该做什么的更多有用信息。例如子进程之一 code.exe
似乎是崩溃的错误报告过程。"C:\Program Files (x86)\Microsoft VS Code\Code.exe" --reporter-url=https://ticinocrashreporter.azurewebsites.net/crash --application-name=VSCode "--crashes-directory=..\AppData\Local\Temp\VSCode Crashes" --v=1
关于process - 单个应用程序窗口的任务管理器中 Visual Studio 代码的多个实例或进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40816178/