Why is IntelliJ IDEA hanging on “Indexing”?

2020-05-14 13:44发布

I'm running on Arch Linux, on an i7-5930k 6 core CPU and 64GB of DDR4 RAM, and I'm using IntelliJ IDEA 14.

IDEA was working just fine for me several days ago, but one day, suddenly, it began hanging after opening a project, during the "Indexing" stage. I did not update IDEA and nothing changed about my projects. The IDE's UI hangs after it opens the project, with just a tiny little sliver of the progress bar for "Indexing" complete. Every 5-10 minutes or so it unfreezes and the progress bar crawls forward a little bit, before the IDE freezes again for another few minutes. This happens repeatedly for anywhere between 15 minutes and an hour, until it is finally finished indexing, at which point it hangs for another 5-10 minutes doing nothing, before it finally unlocks and allows me to develop.

While this is happening, my system is fairly unresponsive - Firefox tabs take a long time to switch, and scrolling in them is laggy. Opening a new terminal window takes a long time. Switching windows in general takes awhile. In htop, one of my CPU cores is loaded at 100% while the rest have a normal load, and about 6GB of RAM is used (fairly normal load when this system is idle.)

Things I have tried that have not helped:

  • Delete caches folder
  • Delete entire ~/.IntelliJIDEA14 folder
  • Reinstall IntelliJ package
  • Download IntelliJ manually from JetBrains' site and run it from my Downloads folder (to see if there was something wrong with the Arch AUR package)
  • Configure IntelliJ to use my system JVM and Maven for importing instead of its embedded tools
  • Opening multiple different projects (not just the one I initially experienced the issue on.)

This issue is really hurting my workflow, if anybody has any solution to this I would be very greatful.

14条回答
放荡不羁爱自由
2楼-- · 2020-05-14 14:12

In my case I found out that Intellij is actually trying to index a 50GB directory with logs that was under the project's root. Make sure that if you have such a directory, it is marked as "Excluded" in the IDE.

You can see which file the IDE is indexing currently in the Indexing Status window (access by clicking on the indexing message in the toolbar). You may need to enlarge this window to see the full path of the file currently being indexed.

查看更多
狗以群分
3楼-- · 2020-05-14 14:15

I had the same problem with IntelliJ 2017.3.2. When I clicked on the indexing progress bar I noticed it was hung on a directory within my build directory. When I did a gradlew clean which removed that directory then the indexing was able to proceed.

查看更多
贪生不怕死
4楼-- · 2020-05-14 14:19

Had the same issue in the past on some Scala project. I have installed IDEA 16 EAP (https://confluence.jetbrains.com/display/IDEADEV/IDEA+16+EAP) and the problem has gone.

查看更多
Lonely孤独者°
5楼-- · 2020-05-14 14:21

I've finally figured it out. The solution was... Rather odd. TL;DR: Run it under strace. Read on for a more detailed explanation.

I came upon it when I decided to run IntelliJ under strace to see what files it was opening to determine whether or not it was a filesystem bottleneck.

This gave me some very strange results: strace was spewing out a near-constant stream of segfaults. Not only that, but IntelliJ was running just fine, not taking forever to index.

After consulting with a friend, I learned that on Arch Linux, systemd logs a dump of a process's memory every time a segfault occurs, except when a debugger is attached. strace is considered a debugger. Arch was thrashing my disks when it kept logging memory dumps due to all the segfaults, hence why the indexing was taking so long, because it was fighting for disk I/O.

My solution for now is to simply run IntelliJ under strace. I will, however, be looking into the issue further, as I don't think java should be segfaulting that much.

查看更多
啃猪蹄的小仙女
6楼-- · 2020-05-14 14:21

seems that there might be several reasons for getting into this "indexing" hell. I spent few hours trying to fix it using the ideas above. At the end of the day, with some profiling work, I found that the bad guy in my case was the csv plugin: https://plugins.jetbrains.com/plugin/10037-csv-plugin

I had few (not so large) CSV files serving as input, and although I marked them as not to be indexed, the plugin kept trying to index them. Once I removed the plugin everything worked fine.

查看更多
forever°为你锁心
7楼-- · 2020-05-14 14:25

edit Intellij[VERSION]/bin/idea.properties, set idea.max.intellisense.filesize=50

update: Intellij will skip index files that size larger than 50kb.try this if you have many libraries or many large files(too many characters one line or too many lines)

查看更多
登录 后发表回答