Profiling Java applications
Profiling is used to make an analysis of the runtime performance of an application. This is something that needs to be done carefully, since it usually has an impact on the application that is being profiled. It is, therefore, advisable to profile the development environment if possible. We are going to have a look at profiling with the jstat
and jmap
command-line tools, and the VisualVM application. The first two come with your Java Development Kit (JDK); the latter used to come with it but now it can be downloaded separately.
Important note
You can download VisualVM here: https://visualvm.github.io/download.html.
There are other profiles out there; some IDEs even have their own profilers built in, which work in a similar way.
Profiling with jstat and jmap
With the two command-line utilities, jstat
and jmap
, we can analyze and profile memory. We are going to explore how to do that.
Let’s say we have a simple Java application:
...