PyCharm running way slow

128,189

Solution 1

Every performance problem with PyCharm is unique, a solution that helps to one person will not work for another. The only proper way to fix your specific performance problem is by capturing the CPU profiler snapshot as described in this document and sending it to PyCharm support team, either by submitting a ticket or directly into the issue tracker.

After the CPU snapshot is analyzed, PyCharm team will work on a fix and release a new version which will (hopefully) not be affected by this specific performance problem. The team may also suggest you some configuration change or workaround to remedy the problem based on the analysis of the provided data.

All the other "solutions" (like enabling Power Save mode and changing the highlighting level) will just hide the real problems that should be fixed.

Solution 2

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

Solution 3

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.

Solution 4

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

Solution 5

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
Share:
128,189
mlnyc
Author by

mlnyc

Updated on August 18, 2022

Comments

  • mlnyc
    mlnyc almost 2 years

    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?

    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

  • Berry Tsakala
    Berry Tsakala over 10 years
    Shouldn't such things run automatically once in a while?
  • Lorenz Lo Sauer
    Lorenz Lo Sauer about 10 years
    @BerryTsakala true and it does usually work quite well. I am not familiar with Jetbrains GC improvements, however here is a pretty good sum-up of 'plain vanilla' GC in JAVA: javarevisited.blogspot.com.es/2011/04/… Cheers!
  • mateuszb
    mateuszb almost 10 years
    ctrl+alt+s -> settings
  • Steve Rossiter
    Steve Rossiter almost 9 years
    I would also disable any plugins you are not using. Double shift and search for "plugins" and untick all those you don't need.
  • Ciasto piekarz
    Ciasto piekarz over 8 years
    Turning off Plugins helps in fast startup.
  • wilblack
    wilblack over 8 years
    Point #1 helped a lot for me, I was about to uninstall and go back to Sublime 3 because i couldn't scroll smoothly, but now PyCharms is usable.
  • Steven Du
    Steven Du about 8 years
    Just want to share that Point #2 works, please excluded your ".git" folder as well ...
  • Chris
    Chris about 8 years
    @CrazyCoder is there anything we can do if PyCharm starts consuming CPU cycles? Previously it would happen while a specific Python file was focused in the editor, but this was fixed with version 5. But now with version 2016.1.2 the IDE seems to randomly start using >50% even with all editor files closed and nothing running and in Power Save mode, and it carries on indefinitely until I close PyCharm, and soon starts again on resuming it. Any idea? Memory is about 200MB (of 725). I'm running OS X 10.11.3, PyCharm build #PY-145.844. This is a big issue for me as I live in a place with power cuts.
  • Chris
    Chris about 8 years
    To clarify, I mean to figure out what PyCharm is stuck on processing. I'm posting as a comment as I don't think PyCharm needs lots of bad SO questions, and I haven't had much luck with issues that aren't obvious bugs on the support process. My fan just stopped for a few hours, and usage went back down to 5%, but it just shot up again. I didn't do anything in PyCharm.
  • CrazyCoder
    CrazyCoder about 8 years
  • Chris
    Chris about 8 years
    It is related to iPython running in the Python Console, possibly trying to run Django while it had errors. Removing ipython from my virtual environment seems to have solved the issue - so far the non-ipython console is not causing the same issue. So nothing to do with PyCharm. Thanks @CrazyCoder for the follow-up.
  • Chris
    Chris about 8 years
    I'm mistaken, it is now happening without iPython running. I've posted a bug report here thanks.
  • Emmel
    Emmel over 7 years
    In OSX, on PyCharm CE 2016.3.2, #1 didn't exist, and for #2 and #3 those shortcuts of course won't work, but I did a CMD-(left) Shift-A, which brings up an 'options search' dialogue to help me find these. For me, having project roots as my whole home directory caused some serious slowdown issues. Thanks for writing this.
  • Yuda Prawira
    Yuda Prawira about 7 years
    is there is a way to increase heap size?
  • Stephen
    Stephen almost 7 years
    All of this may be less of an issue with a 4 physical core (8 logical core) computer. In my case I'm stuck with 2 physical cores (4 logical), so it's more important to manage processes doing local development.
  • Stephen
    Stephen almost 7 years
    Warning: Do not go above Above Normal. If you do this you will compete with Windows processes and possibly cause havoc on your computer. And you would not even make it much faster, if at all.
  • Lutaaya Huzaifah Idris
    Lutaaya Huzaifah Idris over 6 years
    I have done most of the solutions, changing the inspection level , solution 2 and 3 , even i remove some plugins but my pycharm , still freezes when am typing , i am using WIn10 on aa PC of 8gb RAM and i core5 , initially the IDE was working very well , now it continues slowing.
  • Ettore Galli
    Ettore Galli about 6 years
    I had the biggest problems in auto format (I practically issue ctrl+alt+l every two or three lines of code) and the problem arose after generating some very big sources; Solution #2 solved the problem: First I excluded those generated big sources then performed a clear cache and restart and worked again fine. Those big sources are definition of python very large arrays on source (data directly in the source) for test/trial purpose (not for production) so it was fine to exclude them from indexing.
  • Mathews Sunny
    Mathews Sunny almost 6 years
    Add some more deatils here
  • jolvi
    jolvi over 5 years
    "Every performance problem with PyCharm is unique" in other words, PyCharm is unfixable :-( To the contrary, a common non-unique problem seems to be a large data folder in the project that should be exclude from inspection.
  • CrazyCoder
    CrazyCoder over 5 years
    @jolvi thanks for the feedback, there are certainly common cases for the performance problems, but most of them are still different and it would be better to report them to JetBrains with the CPU snapshots and other details so that they can be fixed properly and no workarounds would be required in the future. For example, it may be specific to the file types and data you have in that folder and the snapshot would help to catch the bug and fix it.
  • Appyx
    Appyx over 5 years
    Perfect :) Restarting the IDE should be mentioned.
  • dtadres
    dtadres almost 5 years
    This! If you want to keep the folder in the Project Directory, exclude it from indexing by: right click on the folder you want to exclude, 'Mark Directory as' -> 'Excluded'
  • Stephen
    Stephen about 4 years
    This is the best answer (see JMJ's answer below which gives an easy way to edit it). PyCharm's default memory max of 2GB is a bit low for many users I think.
  • IntegrateThis
    IntegrateThis over 2 years
    This was my exact problem, too many images being stored alongside my code, and by Marking the directory as excluded the slowness/stuttering went away.
  • Andrew
    Andrew about 2 years
    Where to find in PyCharm"drop down (arrow) symbol of your configuration"?
  • Homero Esmeraldo
    Homero Esmeraldo about 2 years
    I couldn't find "Show memory indicator" in settings->Appearance & Behavior->Appearance on PyCharm 2021.2.1 Professional Edition