Webstorm 使用 node.js 变得非常慢

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25765988/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 17:52:30  来源:igfitidea点击:

Webstorm becomes extremely slow with node.js

node.jsperformancewebstorm

提问by Ilan lewin

Anyone knows what's the deal with this IDE? I have been running it for a while, lately it has become very slow and unresponsive at times. Gobbles up CPU even when just editing a bunch of js files.

有谁知道这个IDE是怎么回事?我已经运行它一段时间了,最​​近它有时变得非常缓慢和无响应。即使只是编辑一堆 js 文件,也会占用 CPU。

Possibilities: 1. My code base is getting bigger... 2. I have several listeners which compile coffeescript and sass files in the background when these change.

可能性: 1. 我的代码库越来越大... 2. 我有几个监听器,当这些文件发生变化时,它们会在后台编译 coffeescript 和 sass 文件。

In any case, I am very surprised (for the worse) that this is so slow. Would expect better from a developer of an IDE.

无论如何,我很惊讶(更糟的是)这太慢了。对 IDE 开发人员的期望会更好。

Anyone had this kind of problem before? 10x

以前有人遇到过这种问题吗?10倍

回答by Andrew

There are a couple performance tweaks you can apply to Webstorm to see if it improves your situation. When my colleagues and I found that Webstorm was slowing down these tweaks solved all our problems.

您可以对 Webstorm 应用一些性能调整,看看它是否能改善您的情况。当我和我的同事发现 Webstorm 放慢速度时,这些调整解决了我们所有的问题。

First things first, ensure your project is configured to utilise webstorm resources efficiently by excluding particular directories from a project. This will ensure the containing files are not indexed in memory and will not decrease performance when performing functions such as searching for files or text within files. Some examples of good candidates to exclude are the node_modulesdirectory and compiled code directories.

首先,确保您的项目配置为通过从项目中排除特定目录来有效利用 webstorm 资源。这将确保包含的文件不会在内存中建立索引,并且在执行诸如搜索文件或文件中的文本之类的功能时不会降低性能。要排除的良好候选者的一些示例是node_modules目录和编译代码目录。

If there are still performance issues, try the following:

如果仍然存在性能问题,请尝试以下操作:

If you are on Windows by default you would be using the 32-bit version. Navigate to the Webstorm directory (within program files) and you'll see webstorm64.exe, which will run Webstorm in 64-bit mode. (You might need to install a proper 64-bits JDKyourself then.)

如果您默认使用 Windows,您将使用 32 位版本。导航到 Webstorm 目录(在程序文件中),您将看到webstorm64.exe,它将以 64 位模式运行 Webstorm。(你可能需要自己安装一个合适的 64 位 JDK。)

The default VM options for IntelliJ IDEA may be not optimal when your project contains more than 10000 classes and developers often try to change the default options to minimize IntelliJ IDEA hangtime.

当您的项目包含超过 10000 个类并且开发人员经常尝试更改默认选项以最小化 IntelliJ IDEA 挂起时间时,IntelliJ IDEA 的默认 VM 选项可能不是最佳的。

You can try bumping up the JVM memory limits for Webstorm. Open the VM options from the IDE_HOME\bin\<product>[bits][.exe].vmoptions. Initially try doubling the Xmsand Xmxmemory values.

您可以尝试提高 Webstorm 的 JVM 内存限制。从IDE_HOME\bin\<product>[bits][.exe].vmoptions. 最初尝试将XmsXmx内存值加倍。

Please note that very big Xmx and Xms values are not so good. In this case, GarbageCollector has to work with a big part of memory at a time and causes considerable hang-ups.

请注意,非常大的 Xmx 和 Xms 值不太好。在这种情况下,GarbageCollector 必须一次处理很大一部分内存并导致大量挂断。

For more info on configuring JVM memory options you can refer to:

有关配置 JVM 内存选项的更多信息,您可以参考:

回答by Thilak Rao

I was dealing with a similar situation. CPU used to spike like crazy, and the IDE used to lag. Go to WebStorm preference and try disabling plugins that you do not need.

我正在处理类似的情况。CPU 曾经疯狂飙升,而 IDE 曾经滞后。转到 WebStorm 首选项并尝试禁用您不需要的插件。

For instance, if your project uses SASS, what's the point of having LESS plugin running? Likewise, if your project uses Git, you don't need to have CVS or Perforce Integration.

例如,如果您的项目使用 SASS,那么运行 LESS 插件有什么意义?同样,如果您的项目使用 Git,则不需要 CVS 或 Perforce 集成。

Disable Plugins that you don't need

禁用不需要的插件

CPU still spikes when WebStorm is indexing my project files, but I usually just wait it out.

当 WebStorm 索引我的项目文件时,CPU 仍然会出现峰值,但我通常只是等待它。

回答by Lukas Liesis

You can now do it from UI.

您现在可以从 UI 执行此操作。

enter image description here

在此处输入图片说明

These are my before-after. No problems with the garbage collector. Just multiplied all values by 4. Machine: 20Gb RAM, 4Ghz i7 CPU & SSD disk. With defaults it started to lag. Now no lag again.

这些是我的前后对比。垃圾收集器没有问题。只需将所有值乘以 4。机器:20Gb RAM、4Ghz i7 CPU 和 SSD 磁盘。默认情况下,它开始滞后。现在不再滞后。

Pasting as text for quick copy:

粘贴为文本以进行快速复制:

# custom WebStorm VM options
# Default:
# -Xms128m
# -Xmx750m
# -XX:ReservedCodeCacheSize=240m
# -XX:+UseCompressedOops

-Xms512m
-Xmx3000m
-XX:ReservedCodeCacheSize=960m
-XX:+UseCompressedOops