[pycharm] pycharm running way slow

I'm a big fan of PyCharm by JetBrains but I do run into some issues that I thought maybe I'll ask here about.

  1. It hangs unexpectedly and this happens often. Overall, its a little bit slow for my taste and I would love some tips on how to increase the performance of the IDE
  2. Often when I open a project PyCharm seems to flag all the built-ins as Unresolved Reference warnings. things like open(), str(), etc. as well as some of the modules I import such as sys (these are the most common offenders :) ).

The only way I am able to fix (2) is by going to PyCharm -> Preferences -> Python Interpreters -> Paths -> Reload List of Paths but I have to do this often enough to warrant asking about a more permanent fix.

My configuration: Mac OSX Lion running on MacBook Pro (mid 2010) with 8GB RAM

Now look, I understand that diagnosing things like these is difficult without any sort of snapshot or more information about what is going on, but I am simply asking if anyone has ran into these issues before and if so, how did these get resolved?

Thanks!

P.S. I have also contacted JetBrains regarding these issues, but honestly I tend to find nice solutions to common problems here and I thought I might as well ask

This question is related to pycharm

The answer is


In my case, it was very slow and i needed to change inspections settings, i tried everything, the only thing that worked was going from 2018.2 version to 2016.2, sometimes is better to be some updates behind...


1. Change the inspection level

Current PyCharm versions allows you to change the type of static code analysis it performs, and also features a Power/CPU Saving feature (Click on the icon at the bottom right, next to the lock):

enter image description here

2. Change indexed directories
Exclude directories from being indexed which are set in the project paths but not actually required to be searched and indexed. Press ALT+CTRL+S and search for project.

3. Do memory sweeps
There is another interesting feature:

Go into the settings (File/Settings) and search for memory. In IDE Settings>Appearance -> tick Show memory indicator. A memory bar will be shown at the bottom right corner (see the picture below). Click this bar to run a garbage collection / memory sweep.

enter image description here


Well Lorenz Lo Sauer already have a good question for this. but if you want to resolve this problem through the Pycharm Tuning (without turning off Pycharm code inspection). you can tuning the heap size as you need. since I prefer to use increasing Heap Size solution for slow running Pycharm Application.

You can tune up Heap Size by editing pycharm.exe.vmoptions file. and pycharm64.exe.vmoptions for 64bit application. and then edit -Xmx and -Xms value on it.

So I allocate 2048m for xmx and xms value (which is 2GB) for my Pycharm Heap Size. Here it is My Configuration. I have 8GB memory so I had set it up with this setting:

-server
-Xms2048m
-Xmx2048m
-XX:MaxPermSize=2048m
-XX:ReservedCodeCacheSize=2048m

save the setting, and restart IDE. And I enable "Show memory indicator" in settings->Appearance & Behavior->Appearance. to see it in action :

Pycharm slow, slow typing, increase Pycharm Heap Size

and Pycharm is quick and running fine now.

Reference : https://www.jetbrains.com/help/pycharm/2017.1/tuning-pycharm.html#d176794e266


I found a solution to this problem that works beautifully on Windows, and wanted to share it.

Solutions that didn't work: I have 16GB of RAM and was still having horrible lag. PyCharm takes less than 1GB of RAM for me, so that wasn't the issue. Turning off inspections didn't help at all, and I didn't have any special plugins that I recall. I also tried playing around with CPU affinities for the process, which briefly worked but not really.

What worked beautifully, almost perfectly:

  1. Set PyCharm's CPU priority to Above Normal
  2. Set the CPU priority for Python processes to Below Normal

You can do this manually, but I recommend using a program which will preserve the setting across restarts and for multiple instances. I used Process Hacker: Right click on the process -> Priority -> Set the priority. Then right click again -> Process -> and select "Save for pycharm64.exe" and similarly for python "Save for python.exe." Finally in Process Hacker go to Options and select "Start when I log on." This will make it so that ALL Pycharm and python executables acquire these CPU priorities, even after restarting the program and/or Windows, and no matter how many python instances you launch.

Basically, much of the PyCharm's lag may be due to conflict with other programs. Think about it: Yes PyCharm requires a lot of CPU, but the PyCharm developers aren't stupid. They have probably at least ensured it can run without lag on an empty core. But now you open Chrome and 30 tabs, Fiddler, an FTP program, iTunes, Word, Slack, etc, and they all compete with PyCharm at the same CPU priority level. Whenever the sum of all programs > 100% on a core, you see lag. Switching to Above Normal priority gives PyCharm something closer to the empty core that it was probably tested on.

As for Below Normal on python.exe, basically you don't want to slow your computer down with your own development. Most python programs are essentially "batch" programs, and you probably won't notice the extra time it takes to run. I don't recommend this if you are developing a graphical interactive program.


I thought I had a speed issue with PyCharm but in the end it turned out that the output console in PyCharm does not necessarily emulate the output of state-of-the-art terminal applications.

Here's my solution: Click on drop down (arrow) symbol of your configuration -> click edit configuration -> click emulate terminal in output console -> click ok -> Run the configuration.


It is super easy by changing the heap size as it was mentioned. Just easily by going to Pycharm HELP -> Edit custom VM option ... and change it to:

-Xms2048m
-Xmx2048m

In my case, the problem was a folder in the project directory containing 300k+ files totaling 11Gb. This was just a temporary folder with images results of some computation. After moving this folder out of the project structure, the slowness disappeared. I hope this can help someone, please check your project structure to see if there is anything that is not necessary.


Regarding the freezing issue, we found this occurred when processing CSV files with at least one extremely long line.

To reproduce:

[print(x) for x in (['A' * 54790] + (['a' * 1421] * 10))]

However, it appears to have been fixed in PyCharm 4.5.4, so if you experience this, try updating your PyCharm.