PHPStorm/Webstorm将内存增加到512MB以上

时间:2022-05-23 18:10:04

I'm using PHPStorm under Win7 64bit with 64bit Java (latest version I guess) and working currently on an insanely big and chaotic project. There are many classes containing 10k LOC and more. Therefore my PHPStorm runs out of memory once in a while.

我正在win764bit下使用PHPStorm和64bit Java(我猜是最新版本),目前正在开发一个庞大而混乱的项目。有许多类包含10k LOC和更多。因此,我的PHPStorm也会有一段时间内存耗尽。

I get this nice Out-of-Memory dialog suggesting increasing my memory settings. I currently have set in my PhpStorm.exe.vmoptions:

我得到这个不错的内存耗尽对话框,建议增加内存设置。我目前在我的PhpStorm.exe.vmoptions:

-server-Xms128m-Xmx512m-XX:MaxPermSize=250m-XX:ReservedCodeCacheSize=64m-ea-Dsun.io.useCanonCaches=false-Djava.net.preferIPv4Stack=true-XX:+UseCodeCacheFlushing-XX:+UseConcMarkSweepGC-XX:SoftRefLRUPolicyMSPerMB=50

The problem is: When I increase my memory to be used in this file I get the following error when starting the program:

问题是:当我在这个文件中增加内存时,当我启动程序时,会得到以下错误:

Failed to create JVM: Error code -4

创建JVM失败:错误代码-4。

I Googled around but nobody seems to want the memory to be more than 512MB.

我在谷歌上搜索了一下,但似乎没有人希望内存超过512MB。

Does anybody know what I can do to use PHPStorm without any hassle again?

有谁知道我可以做什么来使用PHPStorm而不再有任何麻烦吗?

Sure, I can reset the cache but this is not a permanent solution, right?

当然,我可以重置缓存但这不是一个永久的解决方案,对吧?

I read somewhere that adding this line to my vmoptions is a good idea, but I don't see any difference:

我在什么地方读到过,在我的vmoptions中添加这一行是一个好主意,但我没有看到任何区别:

-server....-XX:MinHeapFreeRatio=15

6 个解决方案

#1


43  

Make sure that PhpStorm use 64-bit Java and not bundled one (which is 32-bit). You an check that in Help | About.

确保PhpStorm使用64位Java,而不是绑定一个(32位)。你的支票在帮助|左右。

Generally speaking: with 64-bit Java you do not have to change that value as it works a bit differently compared to 32-bit one.

一般来说:对于64位Java,您不必更改该值,因为与32位Java相比,它的工作方式略有不同。

1) PhpStorm comes with bundled x86 Java and it is the first one that it tries; only then it looks for other Java installations -- check PhpStorm.bat for details (what environment variables and in which order). By defining one of those environment variables (which will point to your 64-bit Java installation) you can tell PhpStorm to use instead of bundled one.

1) PhpStorm自带x86 Java捆绑,是PhpStorm尝试的第一个;只有这样,它才会查找其他Java安装——检查PhpStorm。获取详细信息(环境变量和顺序)。通过定义其中一个环境变量(它将指向64位Java安装),您可以告诉PhpStorm使用而不是绑定一个环境变量。

2) PhpStorm v8 (currently in EAP stage) comes with 64-bit specific files: you should use PhpStorm64.exe and not PhpStorm.exe (same for .vmoptions file -- it should be PhpStorm64.exe.vmoptions).

2) PhpStorm v8(目前正在EAP阶段)附带64位特定文件:您应该使用PhpStorm64。exe而不是PhpStorm。exe(对于.vmoptions文件也是一样——应该是PhpStorm64.exe.vmoptions)。

I'm not sure how PhpStorm v7 works with 64-bit Java -- have never tried it this way myself.

我不确定PhpStorm v7如何与64位Java一起工作——我自己从来没有尝试过这种方式。


Selecting the JDK version the IDE will run under

选择IDE将运行的JDK版本

https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under

https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under

#2


64  

Changing memory settings for PHPStorm now has a menu option:PHPStorm/Webstorm将内存增加到512MB以上

改变PHPStorm的内存设置现在有一个菜单选项:

#3


30  

After reading this post, I switched to 64bit version (after installing correct JDK) and increased designated memory to 2GB just to shut it up. But I still hit the ceiling, freezes et.c.

读完这篇文章后,我切换到64位版本(安装了正确的JDK之后),并将指定内存增加到2GB以关闭它。但是我还是碰到了天花板。

Eventually realized, that I had my bower_componentsfolder tracked. Folders like this with tons of javascript-files et.c. will basically eat all ram in the world (I also exclude node_modules folder now, same story). So I right-clicked the folder > Mark directory as > Exluded. After some garbage-collection, bumped PhpStorm's memory footprint down to 5-600mb, which seems reasonable.

最终我意识到,我的bower_componentsfolder容器被跟踪了。像这样的文件夹有大量的javascript文件等等。将基本上吃掉世界上所有的ram(我现在也排除node_modules文件夹,同样的故事)。所以我右键点击了文件夹>标记目录作为>的输出。经过一些垃圾收集之后,PhpStorm的内存占用减少到5-600mb,这似乎是合理的。

#4


11  

PhpStorm 2016.1 and newer

PhpStorm 2016.1和更新

As of PhpStorm 2016.1 instead of WEBIDE_JDK_64 one should use JAVA_HOME environment variable that should point to your JVM path.

从PhpStorm 2016.1开始,应该使用JAVA_HOME环境变量来代替WEBIDE_JDK_64,该变量应该指向JVM路径。

Versions prior PhpStorm 2016.1

2016.1版本之前PhpStorm

Like it was mentioned in the @LazyOne's answer, as of PhpStorm v8 (already released), you can use PhpStorm64.exe. But I wasn't able to find any description on how to specify the JVM path for it. The document that explains how to select the JDK version, seems to be a bit outdated.

就像@LazyOne的答案中提到的,在PhpStorm v8(已经发布)中,您可以使用PhpStorm64.exe。但是我找不到任何关于如何为它指定JVM路径的描述。解释如何选择JDK版本的文档似乎有点过时了。

After some research, I discovered that you should create WEBIDE_JDK_64 environment variable that should point to the JRE 64-bit installation path. After doing this, you will be able to start PhpStorm64.exe.

经过一些研究,我发现应该创建WEBIDE_JDK_64环境变量,该变量应该指向JRE 64位安装路径。这样做之后,您就可以开始PhpStorm64.exe了。

By default it sets max memory to 750mb. If you need more, you can modify the C:\Program Files (x86)\JetBrains\PhpStorm 8\bin\PhpStorm64.exe.vmoptions. The better idea, however, would be to edit your user's vmoptions file. Just copy C:\Program Files (x86)\JetBrains\PhpStorm 8\bin\PhpStorm64.exe.vmoptions to %USERPROFILE%\.IntelliJIdea12\idea.vmoptions and set -Xmx750m to a higher value.

默认情况下,它将最大内存设置为750mb。如果你需要更多的,你可以修改C:\Program Files (x86)\JetBrains\PhpStorm 8 \ bin \ PhpStorm64.exe.vmoptions。不过,更好的方法是编辑用户的vmoptions文件。复制C:\Program Files (x86)\JetBrains\PhpStorm 8 \ bin \ PhpStorm64.exe。vmoptions % USERPROFILE % \ .IntelliJIdea12 \想法。vmoptions并将-Xmx750m设置为更高的值。

#5


3  

Simply File > Invalidates Caches / Restart... works for me. ????????

简单的文件>使缓存失效/重新启动…为我工作。????????

#6


1  

I found a log file in the application which grew from a few KB to over 2 GB during a few seconds due to a bug. Webstorm was trying to index this 2 GB log file and running out of memory. Deleting the log file solved the problem (and then fixing the bug prevented the log file from growing).

我在应用程序中发现了一个日志文件,由于一个错误,它在几秒钟内从几KB增加到超过2 GB。Webstorm试图索引这个2 GB的日志文件并耗尽内存。删除日志文件解决了这个问题(然后修复bug,防止日志文件的增长)。

Prior to this I also tried running the x64 JDK and increasing XMX to 2048. But in the end a 64 bit environment with 2048 MB wasn't enough (even though 512 MB was always enough before).

在此之前,我还尝试运行x64 JDK并将XMX增加到2048。但最终,使用2048 MB的64位环境是不够的(尽管以前512 MB总是足够的)。

#1


43  

Make sure that PhpStorm use 64-bit Java and not bundled one (which is 32-bit). You an check that in Help | About.

确保PhpStorm使用64位Java,而不是绑定一个(32位)。你的支票在帮助|左右。

Generally speaking: with 64-bit Java you do not have to change that value as it works a bit differently compared to 32-bit one.

一般来说:对于64位Java,您不必更改该值,因为与32位Java相比,它的工作方式略有不同。

1) PhpStorm comes with bundled x86 Java and it is the first one that it tries; only then it looks for other Java installations -- check PhpStorm.bat for details (what environment variables and in which order). By defining one of those environment variables (which will point to your 64-bit Java installation) you can tell PhpStorm to use instead of bundled one.

1) PhpStorm自带x86 Java捆绑,是PhpStorm尝试的第一个;只有这样,它才会查找其他Java安装——检查PhpStorm。获取详细信息(环境变量和顺序)。通过定义其中一个环境变量(它将指向64位Java安装),您可以告诉PhpStorm使用而不是绑定一个环境变量。

2) PhpStorm v8 (currently in EAP stage) comes with 64-bit specific files: you should use PhpStorm64.exe and not PhpStorm.exe (same for .vmoptions file -- it should be PhpStorm64.exe.vmoptions).

2) PhpStorm v8(目前正在EAP阶段)附带64位特定文件:您应该使用PhpStorm64。exe而不是PhpStorm。exe(对于.vmoptions文件也是一样——应该是PhpStorm64.exe.vmoptions)。

I'm not sure how PhpStorm v7 works with 64-bit Java -- have never tried it this way myself.

我不确定PhpStorm v7如何与64位Java一起工作——我自己从来没有尝试过这种方式。


Selecting the JDK version the IDE will run under

选择IDE将运行的JDK版本

https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under

https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under

#2


64  

Changing memory settings for PHPStorm now has a menu option:PHPStorm/Webstorm将内存增加到512MB以上

改变PHPStorm的内存设置现在有一个菜单选项:

#3


30  

After reading this post, I switched to 64bit version (after installing correct JDK) and increased designated memory to 2GB just to shut it up. But I still hit the ceiling, freezes et.c.

读完这篇文章后,我切换到64位版本(安装了正确的JDK之后),并将指定内存增加到2GB以关闭它。但是我还是碰到了天花板。

Eventually realized, that I had my bower_componentsfolder tracked. Folders like this with tons of javascript-files et.c. will basically eat all ram in the world (I also exclude node_modules folder now, same story). So I right-clicked the folder > Mark directory as > Exluded. After some garbage-collection, bumped PhpStorm's memory footprint down to 5-600mb, which seems reasonable.

最终我意识到,我的bower_componentsfolder容器被跟踪了。像这样的文件夹有大量的javascript文件等等。将基本上吃掉世界上所有的ram(我现在也排除node_modules文件夹,同样的故事)。所以我右键点击了文件夹>标记目录作为>的输出。经过一些垃圾收集之后,PhpStorm的内存占用减少到5-600mb,这似乎是合理的。

#4


11  

PhpStorm 2016.1 and newer

PhpStorm 2016.1和更新

As of PhpStorm 2016.1 instead of WEBIDE_JDK_64 one should use JAVA_HOME environment variable that should point to your JVM path.

从PhpStorm 2016.1开始,应该使用JAVA_HOME环境变量来代替WEBIDE_JDK_64,该变量应该指向JVM路径。

Versions prior PhpStorm 2016.1

2016.1版本之前PhpStorm

Like it was mentioned in the @LazyOne's answer, as of PhpStorm v8 (already released), you can use PhpStorm64.exe. But I wasn't able to find any description on how to specify the JVM path for it. The document that explains how to select the JDK version, seems to be a bit outdated.

就像@LazyOne的答案中提到的,在PhpStorm v8(已经发布)中,您可以使用PhpStorm64.exe。但是我找不到任何关于如何为它指定JVM路径的描述。解释如何选择JDK版本的文档似乎有点过时了。

After some research, I discovered that you should create WEBIDE_JDK_64 environment variable that should point to the JRE 64-bit installation path. After doing this, you will be able to start PhpStorm64.exe.

经过一些研究,我发现应该创建WEBIDE_JDK_64环境变量,该变量应该指向JRE 64位安装路径。这样做之后,您就可以开始PhpStorm64.exe了。

By default it sets max memory to 750mb. If you need more, you can modify the C:\Program Files (x86)\JetBrains\PhpStorm 8\bin\PhpStorm64.exe.vmoptions. The better idea, however, would be to edit your user's vmoptions file. Just copy C:\Program Files (x86)\JetBrains\PhpStorm 8\bin\PhpStorm64.exe.vmoptions to %USERPROFILE%\.IntelliJIdea12\idea.vmoptions and set -Xmx750m to a higher value.

默认情况下,它将最大内存设置为750mb。如果你需要更多的,你可以修改C:\Program Files (x86)\JetBrains\PhpStorm 8 \ bin \ PhpStorm64.exe.vmoptions。不过,更好的方法是编辑用户的vmoptions文件。复制C:\Program Files (x86)\JetBrains\PhpStorm 8 \ bin \ PhpStorm64.exe。vmoptions % USERPROFILE % \ .IntelliJIdea12 \想法。vmoptions并将-Xmx750m设置为更高的值。

#5


3  

Simply File > Invalidates Caches / Restart... works for me. ????????

简单的文件>使缓存失效/重新启动…为我工作。????????

#6


1  

I found a log file in the application which grew from a few KB to over 2 GB during a few seconds due to a bug. Webstorm was trying to index this 2 GB log file and running out of memory. Deleting the log file solved the problem (and then fixing the bug prevented the log file from growing).

我在应用程序中发现了一个日志文件,由于一个错误,它在几秒钟内从几KB增加到超过2 GB。Webstorm试图索引这个2 GB的日志文件并耗尽内存。删除日志文件解决了这个问题(然后修复bug,防止日志文件的增长)。

Prior to this I also tried running the x64 JDK and increasing XMX to 2048. But in the end a 64 bit environment with 2048 MB wasn't enough (even though 512 MB was always enough before).

在此之前,我还尝试运行x64 JDK并将XMX增加到2048。但最终,使用2048 MB的64位环境是不够的(尽管以前512 MB总是足够的)。