Java 为什么 IntelliJ IDEA 挂在“索引”上?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32550292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is IntelliJ IDEA hanging on "Indexing"?
提问by AppleDash
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.
我在 Arch Linux、i7-5930k 6 核 CPU 和 64GB DDR4 RAM 上运行,我使用的是 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.
几天前,IDEA 对我来说工作得很好,但有一天,在“索引”阶段,它突然在打开一个项目后开始挂起。我没有更新 IDEA,我的项目也没有任何改变。IDE 的 UI 在打开项目后挂起,只有一小部分进度条用于“索引”完成。每隔 5-10 分钟左右,它就会解冻一次,进度条会向前爬一点,然后 IDE 再次冻结几分钟。这种情况在 15 分钟到一个小时之间反复发生,直到它最终完成索引,此时它又挂起 5-10 分钟什么都不做,然后它最终解锁并允许我开发。
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.)
发生这种情况时,我的系统反应迟钝 - Firefox 选项卡需要很长时间才能切换,并且在其中滚动很慢。打开一个新的终端窗口需要很长时间。切换窗口通常需要一段时间。在 中htop
,我的一个 CPU 内核以 100% 的速度加载,而其余内核的负载正常,并且使用了大约 6GB 的 RAM(此系统空闲时的负载相当正常。)
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.)
- 删除缓存文件夹
- 删除整个 ~/.IntelliJIDEA14 文件夹
- 重新安装 IntelliJ 包
- 从 JetBrains 的站点手动下载 IntelliJ 并从我的下载文件夹运行它(查看 Arch AUR 包是否有问题)
- 将 IntelliJ 配置为使用我的系统 JVM 和 Maven 进行导入,而不是使用其嵌入式工具
- 打开多个不同的项目(不仅仅是我最初遇到问题的那个。)
This issue is really hurting my workflow, if anybody has any solution to this I would be very greatful.
这个问题真的损害了我的工作流程,如果有人对此有任何解决方案,我将非常感激。
采纳答案by AppleDash
I've finally figured it out. The solution was... Rather odd. TL;DR: Run it under strace
. Read on for a more detailed explanation.
我终于想通了。解决方案是……相当奇怪。TL;DR:在strace
. 继续阅读以获得更详细的解释。
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.
当我决定在 IntelliJ 下运行strace
以查看它正在打开哪些文件以确定它是否是文件系统瓶颈时,我遇到了它。
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.
这给了我一些非常奇怪的结果:strace
正在喷出几乎恒定的段错误流。不仅如此,IntelliJ 运行得很好,不需要永远索引。
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.
在咨询了朋友之后,我了解到在 Arch Linux 上,每次发生段错误时,systemd 都会记录进程内存的转储,除非附加了调试器。strace
被视为调试器。由于所有段错误,Arch 不断记录内存转储时,它正在颠簸我的磁盘,因此为什么索引需要这么长时间,因为它正在争取磁盘 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.
我现在的解决方案是简单地在strace
. 但是,我将进一步研究这个问题,因为我认为不java
应该进行那么多的段错误。
回答by Fabrizio Fortino
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.
过去在某些 Scala 项目中遇到过同样的问题。我已经安装了 IDEA 16 EAP ( https://confluence.jetbrains.com/display/IDEADEV/IDEA+16+EAP),问题已经解决。
回答by BuffK
edit Intellij[VERSION]/bin/idea.properties,
set idea.max.intellisense.filesize=50
编辑 Intellij[VERSION]/bin/idea.properties,设置 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)
更新:Intellij 将跳过大小大于 50kb 的索引文件。如果您有许多库或许多大文件(一行或太多行的字符太多),请尝试此操作
回答by Motti
Try Invalidating the cache and restarting IntelliJ.
In the Filemenu, select Invalidate Caches / Restart...and then click the Invalidate and Restartbutton.
在File菜单中,选择Invalidate Caches / Restart...然后单击Invalidate and Restart按钮。
回答by The Rockncoder
I had this issue as well with version 2016.2 on Mac OS X. I had to do a force quit to end the application, then I deleted the .idea folder. The next time I launched IntelliJ everything worked fine, it had no problem indexing the project.
我在 Mac OS X 上的 2016.2 版也遇到了这个问题。我不得不强制退出以结束应用程序,然后我删除了 .idea 文件夹。下次我启动 IntelliJ 时一切正常,索引项目没有问题。
回答by maaxiim
Select Help -> Debug Log Settings...
选择帮助 -> 调试日志设置...
Add the following line (note the leading # symbol)
添加以下行(注意前导 # 符号)
#com.intellij.util.indexing:trace
#com.intellij.util.indexing:trace
Relaunch the IDE (don't need to invalidate cache as that will cause it to start from scratch, whereas restarting from the point of failure, for me anyway, reported the problem file as soon as I restarted):
重新启动IDE(不需要使缓存失效,因为这会导致它从头开始,而从故障点重新启动,无论如何,我一重新启动就报告问题文件):
Scheduling indexing of file://C:/dev/tools/ruby/lib/ruby/2.2.0/x64-mingw32/win32ole.so by request of index Stubs
根据索引存根的请求调度 file://C:/dev/tools/ruby/lib/ruby/2.2.0/x64-mingw32/win32ole.so 的索引
Our project doesn't use win32ole so I moved the file to a safe location and restarted my IDE... Bingo, problem gone, indexing finally completed after almost 1 year of effectively using intellij as a slightly-smarter-than-notepad ruby editor.
我们的项目不使用 win32ole,所以我将文件移动到一个安全的位置并重新启动了我的 IDE...宾果游戏,问题消失了,在有效使用 intellij 作为比记事本稍微聪明一点的 ruby 编辑器将近 1 年后,索引终于完成了.
回答by seonghuhn
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.
我在 IntelliJ 2017.3.2 上遇到了同样的问题。当我点击索引进度条时,我注意到它挂在我的构建目录中的一个目录中。当我执行 gradlew clean 删除该目录时,索引能够继续进行。
回答by user1978965
I have encountered this problem, and resolved it:
我遇到了这个问题,并解决了它:
- remove idea
- delete all files and dirs which name regex 'jetbrain' and 'IntelliJ' in my computer(Mac mini)
- then install idea
- 删除想法
- 删除我的电脑(Mac mini)中所有命名为正则表达式“ jetbrain”和“ IntelliJ”的文件和目录
- 然后安装想法
I also try just delete idea cache files, it do not work.
我也尝试只删除想法缓存文件,它不起作用。
回答by dux2
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.
就我而言,我发现 Intellij 实际上是在尝试使用项目根目录下的日志来索引一个 50GB 的目录。确保如果您有这样的目录,它在 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.
您可以在“索引状态”窗口中查看 IDE 当前正在索引哪个文件(通过单击工具栏中的索引消息访问)。您可能需要放大此窗口以查看当前正在编制索引的文件的完整路径。
回答by Andrew
In PhpStorm, what solved this for me was excluding folders I didn't need to be indexed from the indexing (specifically the vendor folder, a caches folder, and a few asset folders that contained thousands of images). Instantly it began making progress and completed.
在 PhpStorm 中,为我解决这个问题的是排除我不需要从索引中索引的文件夹(特别是供应商文件夹、缓存文件夹和一些包含数千张图像的资产文件夹)。立即它开始取得进展并完成。
To do this:
去做这个:
- in the project directory list, right click the folder you want to exclude
- Mark Directory As
- Excluded
- 在项目目录列表中,右键单击要排除的文件夹
- 将目录标记为
- 排除