Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does VisualVm does not show all threads in a running tomcat?

My tomcat (version: 5.5.25) runs an application which I try to profile with VisualVM (ver: 1.3.2). Everything looks nice but not all classes and methods are shown in visualVM. They ones that are missing run in thread [main]. I know this because this is the thread's name I receive if I a breakpoint has been hit. Classes which run outside main e.g. [worker1] , [worker2], ... are shown correctly.

Any idea what the reasons might be? Or what I could try?

Since the application I run (it is called Assentis Docbase) is closed-source they might have customized the default tomcat configuration. But they allowed me to extend the framework with my own classes and that are the ones I want to profile.

VisualVM I run with the default configuration as downloaded.

like image 811
EhmKah a.k.a. Michael Krauße Avatar asked Jul 25 '11 08:07

EhmKah a.k.a. Michael Krauße


People also ask

How do I monitor JVM threads?

The simplest way to see the number of threads in Java is to use a graphical tool like Java VisualVM. Apart from the application threads, Java VisualVM also lists the GC or any other threads used by the application like JMX threads. Monitoring the number of threads is the most basic feature in Java VisualVM.

How do I monitor VisualVM?

Under the Local node in the Applications window, right-click the application node and choose Open to open the application tab. Click the Profiler tab in the application tab. Click Memory or CPU in the Profiler tab. When you choose a profiling task, VisualVM displays the profiling data in the Profiler tab.

What is Profiler in VisualVM?

The Profiler tab of an application enables you to start and stop the profiling session of a local application. Profiling results are displayed in the Profiler tab. You can use the toolbar to refresh the profiling results, invoke garbage collection and save the profiling data.


3 Answers

You probably need to customize profiling root methods. See Profiling With VisualVM, Part 1 and Profiling With VisualVM, Part 2. You can also use 'Sampler' tab to get high-level picture of what is your Tomcat doing.

like image 149
Tomas Hurka Avatar answered Sep 28 '22 19:09

Tomas Hurka


Here are a couple of reasons why you may not be able to see the "main" thread:

  • The thread could have exited.

  • The thread could have changed its name by calling Thread.setName().

If you want to figure out the real reason, you will probably need to look at the Tomcat source code.


This page tells you where the settings are. Google is your friend.

like image 30
Stephen C Avatar answered Sep 28 '22 19:09

Stephen C


The reason why VisualVM did not show my method calls in thread [main] is that VisualVM allows only to profile up to 32 threads simoultanously. It is NOT possible to allow more threads to be watched. This has been documented in Profiling With VisualVM, Part 2, section "Comparison With The NetBeans Profiler" they say:

"Profiled threads limit is always 32."

:-(

like image 37
EhmKah a.k.a. Michael Krauße Avatar answered Sep 28 '22 20:09

EhmKah a.k.a. Michael Krauße