Installation

Interface


End

JStack Analyzer Interface

Here is a screen shot of the naked interface:

This isn't very interesting yet. Let's jump into the File menu, which has the following menu items:

Note, the Acquire menu item is only enabled if the JDK tools.jar library is made available on the classpath. Read more about this below under Acquire JStacks.

The File->Open menu item will pop up a file browser dialog, which you can use to select a jstack output file. You should note that there are multiple formats for jstack output (depending on platform and JDK version). If you run across a jstack that isn't supported by JStack Analyzer, you can upload it via this form and it's format will eventually be supported (be sure to include the JDK version and platform it came from). In any case, here is what the output of an idle WebLogic server JVM might look like:

I realize that an idle server doesn't really demonstrate the full diagnostic ability of JStack Analyzer, but I don't have any real stacks that I can share and writing sample applications is too time consuming.

The first field displays Threads by State. All JVM threads have a state associated with them as described by the Thread.State documentation. If you have 100 threads in a BLOCKED state, it should be pretty obvious from this field that you have some sort of bottleneck (i.e. check the relevant threads still in RUNNABLE state). Note that the number in square brackets to the far right of each node displays the number of threads underneath it and that the root nodes representing each state are ordered highest to lowest. This screen shot shows some drill down into the tree:

The next field down displays Threads by Method. The method refers to the line at the top of the stack. Sometimes a bottleneck or hotspot does not cause threads to block; sometimes the problematic threads are all RUNNABLE. If this is the case, analyzing threads by state won't help you. However, if there is a specific method in a specific class that is the problem, this field should highlight it. Once again, note that the number in square brackets to the far right of each node displays the number of threads underneath it and that the root nodes representing the top level method are ordered from highest to lowest. This screen shot shows some drill down into the tree:

The last thread data field displays Identical Threads. Each root node groups together threads which have the exact same methods in each stack. This view highlights when many of a JVM's threads are doing the exact same work. In a healthy JVM, it may be perfectly acceptable, but sometimes it may highlight a bottleneck. Again, note that the number in square brackets to the far right of each node displays the number of threads underneath it and that the root nodes representing the identical thread stacks are ordered from highest to lowest. This screen shot shows some drill down into the tree:

Search

The bottom of the screen provides the means to search the stack displayed in the Threads by State, Threads by Method, and Identical Threads fields. This search facility helps to highlight (literally) information you are looking for, which you might otherwise gloss over accidentally if there is too much stack information to process manually. This screen shot shows the result for a search for ExecuteThreads:

You'll notice on the far right there are checkboxes for RegEx and All JStacks. If the RegEx checkbox is selected, it will treat the search term as a Java regular expression. You should be warned that regular expression search are much more resource intensive than a simple String.indexOf(...) search (which is the default). The All JStacks checkbox will determine whether you search the JStack output for the currently selected tab or all tabs. Obviously search multiple tabs will consume more resources than just the current tab (especially noteworthy when using regular expressions).

Acquire JStacks

Earlier we used the File menu to load an exist JStack file. This is handy if you already have the JStack data in a file. However, JStack Analyzer can extract the JStack data from a running JVM, which may be even be even handier. However, two conditions must be met:

Assuming you have tools.jar available on the classpath, clicking the File->Acquire menu item will present you with the following dialog:

The Acquire StackTrace Properties allows you to set the number of times to invoke the jstack behaviour, the interval between each invocation, and the JVM for which you are interested in. In the screen show above, the defaults are used except I have selected to extract JStacks from a JVM running Eclipse. The Eclipse JVM doesn't provide a description and hence just the process ID (1588) is displayed. Once you click Okay, JStack Analyzer will start extracting jstack data at the specified intervals and add tabs to the display accordingly. Here is the interface with the newly acquired Eclipse jstacks:

Multi-JStack Analysis

There are two views available in JStack Analyzer. Until now, we have been examining a single JStack output and have been entirely concerned with the Single tab. Now, that we have multiple, JStacks, we can look at the Multi tab. This tab is designed specifically for comparing JStacks taken at intervals of the same JVM. Hence, before going any further, we should kill the WebLogic tab...

...as it is from a different JVM. Now let's select the Multi tab. Here is what you would see:

Naturally, there isn't much to see here. All jstacks are doing the same thing and there isn't anything problematic happening. In any case, here is what is being presented. On the far left, there is a column, which displays a thread name and method (separated by a colon). The columns to the right represent values for a given jstack output. The value is the state of the thread as specified in the Thread/Method column. The table is sorted from highest to lowest by the count of the Thread/method row with the most columns with the same state. (WTF did you just say!?!). In simpler terms, the table intends to highlight activity which is constant between jstacks. If an entry in the Thread/Method column is in the same state in every jstack, it will appear in a row toward the top of the table. On the contrary, when a Thread/Method doesn't appear in all jstack columns or has multiple states, it will appear further down in the table. Application threads which have entered into an infinite loop or perhaps are blocking on some deadlock, will all show up at the top of the table. There will likely be healthy threads at the top of the table, but they likely look the same whether the JVM is healthy or unhealthy (that will take some deduction work on your part).

Lastly, as seen in the screen shot above, if you click on any of the jstack cells in the table, the stack for that cell will be displayed in the bottom half of the split pane of the Multi view.


Installation

Interface


End