PHPStorm/Webstorm increase memory to more than 512MB
Asked Answered
A

7

61

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.

I get this nice Out-of-Memory dialog suggesting increasing my memory settings. I currently have set in my 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

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

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

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:

-server
....
-XX:MinHeapFreeRatio=15
Adrian answered 28/8, 2014 at 10:2 Comment(6)
Are you sure that you are using 64-bit Java? What "Help | About" says about Java version used? "I googled around but nobody seems to want the memory to be more than 512MB" -- that's correct GC will be quite annoying.Congeal
wtf...you are right, it says java x86. Why is PHPStorm not taking the main java installed on the system?Adrian
Because 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. 2) You should use PhpStorm64.exe and not PhpStorm.exe (same for .vmoptions file -- it should be PhpStorm64.exe.vmoptionsCongeal
NOTE: I'm talking about PhpStorm v8 (currently in EAP stage) and not v7 -- which does not have those 64-bit specific files.Congeal
ah! ok... well :) is v8 stable enough for working with it?Adrian
Why don't you give it a try? It works OK for me (rather small projects).. but I have no clue how it will behave on your computer/projects (especially considering your requirements) -- it's an EAP build after all -- not all code is optimised for speed and memory consumption (I'm sure you know how software development works: working feature first -- optimisations later).Congeal
C
46

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

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.

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.

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).

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


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

Congeal answered 28/8, 2014 at 10:46 Comment(7)
I seems that it doesn't like the 64bit at all. I added the WEBIDE_JDK enviroment var and now nothing is happening when I want to start the program...Adrian
intellij-support.jetbrains.com/entries/… -- maybe you have provided wrong path?Congeal
I'm pretty sure I have the right path... But the v8 seems to work and I can manipulate the memory settings! Do you know if this option is good to use: XX:MinHeapFreeRatio=15?Adrian
Sorry -- not a Java/JVM person, at all.Congeal
In order to solve this one it was a combination of this answer and the bottom answer.Arid
Thank for information, I just do this for WebStorm and it's working better now.Synergetic
I had an 81MB xdebug profiler output I tried to open in PhpStorm 9.0.2. After over 10 minutes of trying, it gave me "out of memory" error. I realized I was running 32 bit PHPS. I increased Xmx to 2048 from 512, but then PHPS32 wouldn't start an all (why?). I tried PHPS64, but I was missing the JDK, so it wouldn't start either. After installing 64 bit JDK from here (oracle.com/technetwork/java/javase/downloads/…), PHPS64 started, but still ran out of memory after 10 minutes with default Xms of 750. But after I increased Xms to 2048, the profile opened in 2s!Oregano
K
112

Changing memory settings for PHPStorm now has a menu option:

enter image description here

Kulturkampf answered 27/6, 2016 at 11:15 Comment(3)
Good hint but the problem was that we couldn't increase the memory because of the 32bit limitations.Adrian
I know, but though that maybe someone will need only to change memory and because SO is already like devs wiki.Af
thanks, i got a $3k macbook pro with 16gb ram still slows down after 2-3 hours of work, increased to 2.5gb let's see how this works out.Schifra
C
46

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

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.

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.

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).

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


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

Congeal answered 28/8, 2014 at 10:46 Comment(7)
I seems that it doesn't like the 64bit at all. I added the WEBIDE_JDK enviroment var and now nothing is happening when I want to start the program...Adrian
intellij-support.jetbrains.com/entries/… -- maybe you have provided wrong path?Congeal
I'm pretty sure I have the right path... But the v8 seems to work and I can manipulate the memory settings! Do you know if this option is good to use: XX:MinHeapFreeRatio=15?Adrian
Sorry -- not a Java/JVM person, at all.Congeal
In order to solve this one it was a combination of this answer and the bottom answer.Arid
Thank for information, I just do this for WebStorm and it's working better now.Synergetic
I had an 81MB xdebug profiler output I tried to open in PhpStorm 9.0.2. After over 10 minutes of trying, it gave me "out of memory" error. I realized I was running 32 bit PHPS. I increased Xmx to 2048 from 512, but then PHPS32 wouldn't start an all (why?). I tried PHPS64, but I was missing the JDK, so it wouldn't start either. After installing 64 bit JDK from here (oracle.com/technetwork/java/javase/downloads/…), PHPS64 started, but still ran out of memory after 10 minutes with default Xms of 750. But after I increased Xms to 2048, the profile opened in 2s!Oregano
D
36

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.

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 node_modules folder > Mark directory as > Exluded. After some garbage-collection, bumped PhpStorm's memory footprint down to 5-600mb, which seems reasonable.

Discretional answered 20/8, 2015 at 21:30 Comment(5)
Crazy memory/cpu usage has been killing me for weeks. This fixed it right away. Thanks!Tiernan
Currently you must set the environment variable for the jdk OR edit the startup batch file. Then you must always start Webstorm with a batch file to use x64 (as of now). Here are IntelliJ's instructions for switching to the 64-bit JDK: intellij-support.jetbrains.com/hc/en-us/articles/…Outbreak
yup mark directory -> excluded is a life saver, this needs to be in JetBrains docsEnrichetta
Wow.... excluding vendor & giant asset folders. . . saved the day instantly, thanks! (PhpStorm)Gunrunning
Few years ago excluding directories worked for me very well. But with 2022 version I had to really delete logs and other temp files from excluded directories to reduce memory usage. However it's different with node_modules: excluding this directory helps.Ergonomics
F
11

PhpStorm 2016.1 and newer

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

Versions prior PhpStorm 2016.1

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.

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.

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.

Fireplug answered 5/10, 2014 at 13:52 Comment(0)
A
6

Simply File > Invalidates Caches / Restart... works for me. 👌😀

Anteater answered 21/6, 2017 at 15:58 Comment(1)
Thx for the tip :)Footgear
B
5

Help -> Change Memory Settings -> Update Maximum Heap Size to desired value. This fixed issue for me.

Bezoar answered 13/7, 2021 at 1:26 Comment(1)
maybe this is the modern way to go. my post is quite ancient :)Adrian
O
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).

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).

Outbreak answered 18/4, 2016 at 18:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.