Увеличить оперативную память phpstorm
I have installed the EAP of PHPStorm 9 and I am trying to increase my allocated heap size without any luck.
The file /Applications/PhpStorm.app/Contents/bin/idea.vmoptions should be copied to
~/Library/Preferences/WebIdeXX/idea.vmoptions
Any advice would be greatly appreciated! Didn't have any issues with doing the exact same thing for PHPStorm 8.
upd. 12.02.2020
Давно не работал с бутстрапом, тут понадобилось свой фреймворк и бутстрап подключить, а оказывается фича выше подключение Bootstrap 4 через Include Path в PhpStorm больше не работает, а это увы печально и очень плохо, было так удобно, открываешь любой проект, любой кусок когда и везде работал автокомплит, сейчас же осталось два не очень неудобных способа:
- Подключение css в самом html-шаблоне в теге
- Подключение css и js с помощью метки ПКМ по папке -> Mark Directory As ->Resource Root
Вот так это будет выглядеть, css и js папки должны подсвечиваться сиреневым цветом
Автокомплит css и js везде в коде заработает
Теперь и PhpStorm летает и ничего лишнего в автокомплите.
Но такой способ глобального отключения css и js не всегда подходит, на проекте, где я разрабатываю свои модули и фреймворк, там по папкам все раскидано, пока приходится вручную убирать все css и js Битрикса, уверен, выход есть, что-нибудь еще придумаю.
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 :
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:
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.
wtf. you are right, it says java x86. Why is PHPStorm not taking the main java installed on the system?
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.vmoptions
NOTE: I'm talking about PhpStorm v8 (currently in EAP stage) and not v7 -- which does not have those 64-bit specific files.
Toolbox App
If you are using the Toolbox App, you can change the maximum allocated heap size for a specific IDE instance without starting it.
Open the Toolbox App, click the settings icon next to the relevant IDE instance, and select Settings .
On the instance settings tab, expand Configuration and specify the heap size in the Maximum heap size field.
If the IDE instance is currently running, the new settings will take effect only after you restart it.
If you are using a standalone instance not managed by the Toolbox App, and you can't start it, it is possible to manually change the -Xmx option that controls the amount of allocated memory. Create a copy of the default JVM options file and change the value of the -Xmx option in it.
Besides the standard options available , PhpStorm enables you to perform low-level configuration of the underlying platform and the Java runtime.
This may lead to unexpected problems and make your PhpStorm installation inoperable if you are not sure what you are doing. Contact JetBrains Support for instructions regarding the options and values that might help you with whatever issue you are trying to solve.
5. Подключение Bootstrap в PhpStorm
Если все css и js исключить глобально, тогда, например, подключенный в шаблоне сайта Bootstrap не будет в автокомплите, только в том файле, где подключали локально.
В этом случае все сторонние библиотеки можно подключить в Include Path
Для этого я содержу специальную папку и добавляю ее сюда, где плюсик справа.
Содержимое этой папки
Все, после подключения Bootstrap 4 в PhpStorm он будет видеть его глобально по всему проекту, автокомплит классов Bootstrap 4 будет работать везде.
Если зажать клавишу Ctrl и кликнуть мышью по классу btn , то PhpStorm откроет подключенный мной файл bootstrap.css
Enable the memory indicator
PhpStorm can show you the amount of used memory in the status bar. Use it to judge how much memory to allocate.
Right-click the status bar and select Memory Indicator .
7 Answers 7
Changing memory settings for PHPStorm now has a menu option:
I know, but though that maybe someone will need only to change memory and because SO is already like devs wiki.
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.
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
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.
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 ?
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_components folder 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.
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.
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.
1. Отключаем неиспользуемые плагины в PHPStorm
Заходим в File > Settings > Plugins и отключаем все лишние плагины, которые вредят нашей продуктивности и часто портят настроение.
Далее, как все отключили, нажимайте Ок, перезагружайте обязательно программу, все, наслаждайтесь скоростью и легкостью работы в PhpStom.
Если отключили лишний плагин, можете найти и включить заново.
Плагины, которые включены у меня:
3. Увеличиваем предел потребляемой памяти в PhpStorm
Включаем в настройках Show memory Indicator
Сохраняем настройки и смотрим справа внизу появится индикатор потребляемой памяти
Вот тут видим сколько ест программа памяти, у меня открыто 20 файлов, загружен проект Битрикс редакция Бизнес.
Проблема тут в том, что по умолчанию в PHPStorm задан лимит на 512Мб памяти, соответственно, когда у меня в среднем открыто 20-30 файлов, то работать в нем невозможно, не хватает ему памяти, в 8 версии еще было нормально, редко подвисал, но в 9 что-то совсем-совсем плохо стало.
Ну, а раз памяти не хватает, пробуем ее добавить, в 9 версии все работает. Находим папку, куда установлена программа, у меня такой путь:
Тут вам нужен какой-то из двух конфигов, их там два, если не знаете, какой используете, все по умолчанию, то 100% 32-битная версия.
PhpStorm.exe.vmoptions - Если вы используете 32-битную версию PHPStorm
PhpStorm64.exe.vmoptions - Если вы используете 64-битную версию PHPStorm
Открываем файл в любом редакторе или блокноте, тут необходимо в параметре -Xmx1024m увеличить значение, например до 1024Мб.
Cохраняем файл, перезагружаем PHPStorm и наслаждаемся скоростью работы.
Иногда даже с 1Gb памяти программа не запускалась, если чуть-чуть уменьшить, например до 980Mb, то без проблем работает, если что, немного уменьшите.
Locate the JVM options file
If you are not sure where PhpStorm is getting its JVM options, check the following:
The location specified by the PHPSTORM_VM_OPTIONS environment variable. If the specified file exists, it will override all other JVM options files.
If the Toolbox App manages your current PhpStorm instance, open the Toolbox App, click next to the relevant IDE instance, and select Settings . Under Configuration , find Java Virtual Machine options and click Edit .
If you are running a standalone PhpStorm instance, check the configuration directory.
If there are no JVM options files defined in the previous locations, PhpStorm will use the default JVM options file. Do not modify it. Use it only to check what are the default options that PhpStorm uses.
Common properties
Users often change the location of the default IDE directories. For more information, see Change the location of IDE directories.
Limits that can affect performance:
Maximum size of files (in kilobytes) that PhpStorm is able to open. Working with large files can affect editor performance and increase memory consumption. The default value is 20000 .
Maximum size of files (in kilobytes) for which PhpStorm provides coding assistance. Coding assistance for large files can affect editor performance and increase memory consumption. The default value is 2500 .
Maximum size of the console cyclic buffer (in kilobytes). If the console output size exceeds this value, the oldest lines are deleted. To disable the cyclic buffer, set idea.cycle.buffer.size=disabled .
Maximum size (in kilobytes) that PhpStorm loads for showing past file contents when comparing changes. The default value is 20480 .
PhpStorm provides a number of other properties that define interaction with the environment (window managers, launchers, the file system, and so on). Most of them act like hidden settings (in the sense that they are not evidently exposed), which you may need to enable or disable in certain cases. Change these properties only if advised by JetBrains Support.
Уже почти два года я работаю исключительно в PhpStorm, единственное, что меня в нем напрягало все это время, это периодические подтормаживания когда пишешь код, кажется таким тяжелым, громоздким и неуклюжим монстром, о чем пишут многие в сети и отказываются от него, а вот и зря.
А в остальном все замечательно, все есть, что нужно универсалу в наше время - JS, jQuery, PHP, HTML, CSS и т.д.
Недавно окончательно решил покончить либо с этой проблемой, либо с этим редактором, ну и как всегда, собрался с мыслями.
2. Отключаем Spelling в PhpStorm
Также, для ускорения работы PhpStorm можете отключить надоедливый Spelling (проверку правописания):
Заходим в File > Settings > Editor > Inspections и отключаем Spelling.
Platform properties
PhpStorm enables you to customize various platform-specific properties, such as the path to user-installed plugins and the maximum supported file size. The default properties used to run PhpStorm are specified in the IDE installation directory:
Do not change platform properties in the default file, because it is replaced when PhpStorm is updated. Moreover, in case of macOS, editing this file violates the application signature.
JVM options
PhpStorm runs on the Java Virtual Machine (JVM), which has various options that control its performance. The default options used to run PhpStorm are specified in the IDE installation directory:
Do not change JVM options in the default file, because it is replaced when PhpStorm is updated. Moreover, in case of macOS, editing this file violates the application signature.
Common options
The default values of the JVM options should be optimal in most cases. The following are the most commonly modified ones:
Limits the maximum memory heap size that the JVM can allocate for running PhpStorm. The default value depends on the platform. If you are experiencing slowdowns, you may want to increase this value, for example, to set the value to 2048 megabytes, change this option to -Xmx2048m .
Specifies the initial memory allocated by the JVM for running PhpStorm. The default value depends on the platform. It is usually set to about half of the maximum allowed memory (-Xmx), for example, -Xms1024m .
Specifies the ratio between the size of the young and old generation of the heap. In most cases, a ratio between 2 and 4 is recommended. This will set the size of the young generation to be 1/2 to 1/4 of the old generation correspondingly, which is good when you are often working on one project and only a few files at a time. However, if you are constantly opening new files and switching between several projects, you may need to increase the young generation. In this case, try setting -XX:NewRatio=1 , which will make the young generation as large as the old generation, allowing objects to remain in the young generation for longer.
For more information about the available JVM options, see the java command reference.
upd. 06.12.2017
Универсальный способ, чтобы вручную не убирать все папки install и т.п. из индекса, можно поиграться с исключениями внизу в поле Exclude files , тут исключаем все файлы логи, map.js, css, текстовые, архивы, картинки, шрифты и все папки install .
А вот, что вручную я исключал будет в панели справа, это папки с кэшами, бэкапы, временные, обновления, загрузка файлов и т.д., все что по ПКМ -> Mark Directory as -> Excluded
Мой пример исключений, просто вставьте и нажмите Apply, все исключения в дереве проекта слева станут желто-оранжевыми
Configure platform properties:
Do one of the following to create an empty idea.properties file in the configuration directory that will override the values from the original file:
From the main menu, select Help | Edit Custom Properties .
If you do not have any project open, on the Welcome screen, click Configure and then select Edit Custom Properties .
If you cannot start PhpStorm, manually create an empty idea.properties file in the PhpStorm configuration directory.
If you do not have write access to the PhpStorm configuration directory, you can add the PHPSTORM_PROPERTIES environment variable to specify the location of the idea.properties file. The properties in this file will override the corresponding properties in both the original default file and the one located in the PhpStorm configuration directory.
4. Исключаем из индекса ненужные папки, модули, классы
Это еще один очень хороший, проверенный метод, как ускорить работу PhpStorm, убирайте из индекса все ненужные папки с файлами, модулями, классами, либами и т.д., в том числе папки с кэшами и загрузкой файлов, вообще все ненужное исключайте, заметно шустрее станет срабатывать автокомплит и переиндексация.
Минут 20-40 один раз потратите и каждый день будете наслаждаться замечательной, и лучшей на мой взгляд IDE для работы с проектами, не только на PHP.
Обратите внимание еще на один момент, например, модули и некоторые js-либы я не исключил из индексации, ну чтобы автокомплит и поиск работал по ним, это понятно, а вот например, внутри модуля /bitrix/modules/api.auth/ есть папка /install , она исключена из индекса, так у меня сделано во всех модулях, в ней есть инсталлятор, который может хранить в себе копии компонентов, плагинов, php-классов и т.д. для установки, а когда PhpStorm видит два одинаковых класса автокомплит у этого класса пропадает, он желтой волнистой линией подчеркивает такой класс и пишет что-то типа Duplicated class found
Тут есть неприятная проблемка, не будет искать глобальный поиск по исключенным папкам, но если конкретно тыркнуть папку для поиска, то будет искать, возможно это где-то настраивается, я пока еще не нашел, может у вас получится, но лично мне нужно это очень редко, для поиска по всем классам Битрикса у меня есть еще один тестовый проект, на котором установлены все модули, на нем если что нахожу, что нужно.
2 Answers 2
What you have to do
- Go to your PhpStorm installation directory
- open the .vmoptions file (learn more on JetBrains help)
- increase the value of the Xmx-Setting to a reasonable amount
- restart PhpStorm and enjoy your bigger heap
Two things are important
Keep your Java installation updated
Here are some links for a little more background on what to change and why:
- Check the JetBrains help site for detailed instructions on what files to change
- Learn more about the configuration options of JVM (the info also applies to JDK and JRE)
- Check out my vmoptions on pastebin as an example
- Read about why increasing heap size is a good idea
- If you're interested in getting even better performance with PhpStorm read this post
Note: this settings also apply to WebStorm and IntelliJ IDEA.
Solved, in case anyone needs the solution:
I followed the instructions from the "Tuning PHPStorm" page however this time I copied phpstorm.vmoptions into my Library/Preferences folder, working like a charm.
Clarification: ~/Library/Preferences/WebIdeXX/phpstorm.vmoptions is the file it will check. If you are not sure which .vmoptions file it is using, in phpStorm, in the Help menu choose "Show Log in Finder". In the log file search for vmOptionsFile. When it is working correctly, there is a comma separated list of options files. Mine looks like -Djb.vmOptionsFile=/Applications/PhpStorm.app/Contents/bin/phpstorm.vmoptions,/Users/stevep/Library/Preferences/WebIde90/phpstorm.vmoptions
The Java Virtual Machine (JVM) running PhpStorm allocates some predefined amount of memory. The default value depends on the platform. If you are experiencing slowdowns, you may want to increase the memory heap.
From the main menu, select Help | Change Memory Settings .
Set the necessary amount of memory that you want to allocate and click Save and Restart .
This action changes the value of the -Xmx option used by the JVM and restarts PhpStorm with the new setting.
PhpStorm also warns you if the amount of free heap memory after a garbage collection is less than 5% of the maximum heap size:
Click Configure to increase the amount of memory allocated by the JVM. If you are not sure what would be a good value, use the one suggested by PhpStorm.
Click Save and Restart and wait for PhpStorm to restart with the new memory heap setting.
Configure JVM options
Do one of the following to create a copy of the default file with JVM options in the configuration directory that will override the original file:
From the main menu, select Help | Edit Custom VM Options .
If you do not have any project open, on the Welcome screen, click Configure and then Edit Custom VM Options .
If you cannot start PhpStorm, manually copy the default file with JVM options to the PhpStorm configuration directory.
If you do not have write access to the PhpStorm configuration directory, you can add the PHPSTORM_VM_OPTIONS environment variable to specify the location of the file with your preferred JVM options. This file will override both the original default file and the copy located in the PhpStorm configuration directory.
If you are using the Toolbox App, it manages the installation and configuration directory and lets you configure JVM options for every IDE instance. Open the Toolbox App, click next to the relevant IDE instance, and select Settings .
Читайте также: