Solve the problem of abnormal lag and crash caused by opening too many projects in PhpStorm on Mac

藏色散人
Release: 2021-06-03 18:46:59
forward
5223 people have browsed it

The following tutorial column of phpstorm will introduce to you how to solve the problem of opening too many projects in PhpStorm under Mac, causing abnormal lag and crash. I hope it will be helpful to friends in need. !

Foreword: The author is troubled today by PhpStorm, which causes the application to run out of memory. The speed is as slow as a snail, the heat exhaust fan runs like a tractor, and finally it jumps directly to the memory limit of 750. (Default is 128m-750m) Pop-up window.

Through the activity monitor that comes with Mac, I found that

  1. mds_stores process occupies 6.5G (at first I thought it was the author’s docker container and image, which will be explained later)
  2. com.docker.supervisor occupies 2G of memory (the author uses the docker environment for development)
  3. PhpStorm occupies 6.2G

I am confused. My Mac has only 8G of memory. No wonder the Mac is on strike. If I'm also on strike. Haha

The author went through the tuning step by step, and finally found the reason, so I would like to share the three tuning processes

二 (2) is the solution

一, Modify the configuration file of PhpStorm

vi /Applications/PhpStorm.app/Contents/bin/phpstorm.vmoptions

-Xms512m

-Xmx2048m

-XX:MaxPermSize=350m

-XX:ReservedCodeCacheSize=225m

-XX: UseCompressedOops

After modification, it was found that the used memory will not pop up. 750 (default is 128m-750m) pop-up window, but the computer speed is the same so low! ! ! ! ! Mainly due to insufficient memory.

So, this method is suitable for those who have large memory and want to tune it.

2. Tuning the node_modules directory (solution)

1. Globally ignore the node_modules directory (node_modules will disappear in the project, but it still exists, It is always ignored. It can be run locally, but cannot be packaged.)

The operation is very simple, open PhpStorm>>Preferences>>Editor>>File Types

Add node_modules in the Ignore files and folders option, remember to separate them with semicolons. After saving and restarting the project, I found that PhpStorm, which previously occupied about 6G, only occupied about 1.5G. After hiding node_modules, of course the code prompts in the node_modules component will disappear, but the local npm run dev will still run normally.

I found that the Mac overall became quieter and less agitated. The speed has increased. But the author still feels uncomfortable, because if the package is ready to be packaged online, you will find that an error will be reported if the package cannot be packaged. This is suitable for local development projects that have not yet reached the online level.

One step better.

(Solution) 2. Partially remove the index node_modules directory (not ignored, the node_modules directory can still be found in the project)

After the settings are completed, then PhpStorm>>File>>invalidate Caches Restart clear the cache and restart PhpStorm

3. Release of mds_stores

I have been curious about what mds_stores is before Which process. I searched online and found "mds_stores", which is used by the system to build indexes (some people say that mds_stores freezes more often after upgrading to macOS High Sierra). Then I remembered that the recent Finder search was a bit abnormal, and I couldn't find anything. This was the case before the upgrade. The index supports the search functions of Finder and Spotlight (Mac's own tools). Of course, our code tool PhpStorm also uses the index (node_modules), which is why the second step works!

What we have to do now is to stop the mds_stores process

1. Enter the command in Terminal:

sudo mdutil -a -i off .

But this is not enough, you also need to manually kill the mds_stores process through the Mac's own activity monitor.

2. Restart:

sudo mdutil -a -i on

3. Restart
Restart PhpStorm

4. Summary

Since node_modules are large in size, the larger the project, the more open a few. Then PhpStorm cannot carry it. The first step is suitable for large memory, and those who want to tune it can set it up. The second step is the key. The second step (2) operates node_modules to greatly reduce the indexing pressure. Every time you start the project, you will not actively build the index of node_modules, but you will lose the code prompt function, but in fact acceptable. In the subsequent development, the author will continue to observe whether it works for a long time~

The above is the detailed content of Solve the problem of abnormal lag and crash caused by opening too many projects in PhpStorm on Mac. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template