How to get a thread dump when IDE hangs and doesn't respond

Thread dumps can help to identify IDE performance problems when it locks and user interface doesn't respond.

A dump should be taken exactly at the moment when IDE doesn't respond and will record the thread stack. Recording several thread dumps with 1-2 seconds interval can be also very useful for the problem analysis.

 Automatic thread dumps

IDE runs a special thread that detects when UI is locked for a certain time and takes automatic thread dumps into the logs directory. You will find several folders with the name like threadDumps-freeze-20221117-095348-IU-222.4345.14-5sec. Zip these folders together with the logs and attach to you problem report.

If automatic thread dumps were not generated (for example when the whole IDE process is completely blocked), it is needed to capture thread dumps manually:

jstack

The jstack command line utility can be used to capture a thread dump when the IDE hangs. This tool is provided with the JDK installation and can be found in JAVA_HOME\bin directory or the <ide_installed_path>/jbr/bin (available on the IDE 2021.1 and later version). If you are using Toolbox App, please see this article about <ide_installed_path> location.

To use jstack you need the IDE process identifier (PID). PID can be obtained using jps utility that is located in the same directory as jstack.

jps -l

Example: If you want to use jstack from some_path_to_jdk_bin_folder, open a terminal and run some_path_to_jdk_bin_folder/jps -l (on macOS and Linux) or some_path_to_jdk_bin_folder\jps.exe -l (on Windows).

This command lists the Java processes running on your system along with their main class names.

For example, the output would look like this:

1616 jdk.jcmd/sun.tools.jps.Jps -ml
3616 com.intellij.idea.Main
7628 org.jetbrains.idea.maven.server.RemoteMavenServer36

Find the process ID that ends with com.intellij.idea.Main. If you have multiple JetBrains-based IDEs running, either close the other instances to identify the correct process ID using jps command line or open your system’s Task/Activity Manager and locate the IDE's process ID (you may need to enable the PID, or Process ID, column to view it). In this example, the process ID is 3616.

jstack -l <PID>

Example: If you want to use jstack from some_path_to_jdk_bin_folder and the process ID is 3616, open a terminal and run some_path_to_jdk_bin_folder/jstack -l 3616 (on macOS and Linux) or some_path_to_jdk_bin_folder\jstack.exe -l 3616 (on Windows).

Running jstack with the IDE PID will print the thread dump into console, however it's not very convenient. Use this command to redirect the output to a file:

jstack -l <PID> > dump.txt

To take several dumps repeat this command with different file names, like dump1.txt, dump2.txt, etc.

 Thread dump from the console

If jstack doesn't work, it's possible to start IDE from the console/terminal and take a dump using platform specific ways.

Windows

Use the .bat file named for the product and located in IDE_HOME\bin directory (idea.bat, phpstorm.bat, webstorm.bat, pycharm.bat, rubymine,bat).

Press Ctrl+Break (NOT Ctrl+C) in the console to take a thread dump. Dumps can be long, running with output redirection to a file is recommended, like:

idea.bat > output.txt 2>&1

You can record several dumps in the same file by pressing Ctrl+Break multiple times.

macOS

Browse to the /Applications/<PRODUCT>.app/Contents/MacOS/<product> executable in Finder, in the context menu choose Open With, Terminal. To get a thread dump press Ctrl+\ in the Terminal window.

Linux, Solaris, Generic Unix

Start the IDE from the terminal using the .sh script in the product bin directory. Start another terminal, find the IDE java process ID using jps, ps or your other favorite process manager. Send the QUIT signal to the IDE process:

kill -QUIT <PID>

Thread dump should be printed into the first terminal window from where IDE was started. Use process output to a file redirection to capture long dumps.

69 out of 121 found this helpful
12 comments
Avatar
Permanently deleted user

IDE hangs and doesn't respond, how to fix this issue from last 1 day i am struggling with it. how to kill the thread dumps

1

Please contact support by creating a ticket and attach the thread dumps.

2
Avatar
Permanently deleted user

10.0.3 Webstorm is horribly laggy.  Unresponsive for a few seconds often.  Unusable.  I don't have time to debug your product.

2
Avatar
Permanently deleted user

I have to agree with Darcey here, editing javscript files within PyCharm is waaay slower than even in pycharm 4.0 and hangs so often and hard I have to kill -9 pycharm. It's getting to the point that If you don't improve performance substantially, I"m going to move on to another IDE.

2
Avatar
Permanently deleted user

It's the same here.

I'm using PyCharm 4.5 Professional with a lot of CoffeeScript and Python files and it freezes regularly until the point where I have to kill PyCharm. Without performance updates we will also switch to an alternative.

2
Avatar
Permanently deleted user

Why is PyCharm 4.5 so so slow? Just upgraded to the newer version and am now fighting with the program to do some work!

It hogs the CPU when it feels like it. Any ideas to make PyCharm run smoother and faster??

2
Avatar
Permanently deleted user

Bug report submitted yesterday, all logs/dums are included per instructions above.

https://youtrack.jetbrains.com/issue/PY-16445

2

hi, the article it's now clear where to press the ctr+break? we go to windows terminal and press ctr+break there? 

“Windows

Use the .bat file named for the product and located in IDE_HOME\bin directory (idea.bat, phpstorm.bat, webstorm.bat, pycharm.bat, rubymine,bat).

Press Ctrl+Break (NOT Ctrl+C) in the console to take a thread dump. Dumps can be long, running with output redirection to a file is recommended, like:”

0

Taw Moto Yes, in Windows command line / terminal. It works in both cmd.exe and wt.exe.

0

On macOS, the jstack and jps executables seem to be located in ~/Applications/IntelliJ\ IDEA\ Ultimate.app/Contents/jbr/Contents/Home/bin/, and not in /Applications/IntelliJ\ IDEA\ Ultimate.app/jbr/bin/ as the article suggests.

1

Rather than `jps -mv` which only prints `main` and bunch of meaningless arguments it's much better to invoke `jps -l` which prints full class name:

```
jps -l
71648 com.intellij.database.remote.RemoteJdbcServer
18099 com.intellij.idea.Main
37379 /Users/marcin.wisnicki/Library/Application
88772 jdk.jcmd/sun.tools.jps.Jps
18584 org.sonarsource.sonarlint.core.backend.cli.SonarLintServerCli
1054
```

So in case of intellij `jps -l | grep com.intellij.idea.Main` should do the trick.

0

Quick one-liner:

jstack -l $(jps -l | grep com.intellij.idea.Main | cut -f1 -d\ ) | gzip -9 > dump.txt.gz 

0

Please sign in to leave a comment.

Have more questions?

Submit a request