Lab 6

Dynamic Analysis

Dynamic analysis refers to all methods that aim to analyze the execution/s of an application.

Dynamic analysis tools usually analyze an application with respect to

  • resource consumption: execution times for subroutines or software modules, used memory footprint, database queries / REST requests
  • different types of programming flaws or errors: memory leaks, race conditions, segmentation faults, division by zero etc.

JVisual VM

JVisualVM is a simple and easy to use dynamic analysis software. The application is distributed by Oracle together with the Java JDK, or can also be downloaded from its official page: https://visualvm.github.io/download.html. You can download JVisual 2.0.4 or later for MacOS, for Linux or Windows (choose the version that best suits you needs from here).

The application can be started from the console, by simply typing jvisualvm in the console (see also). All currently running Java applications will be shown in the upper left part of the screen. In order to start the analysis it is enough to double click on the application you wish to analyze. A tab menu will show you all the options the tool is offering.

You will use the attached Eclipse project to try on the dynamic analysis features of JVisualVM. First save profiler-project.zip, then import the project in Eclipse using the menu File -> Import -> General -> Existing Projects into Workspace. Run and analyze.

YourKit Java Profiler

YourKit Java Profiler is a dynamic analysis software quite similar to JVisualVM, but it is a commercial tool, offering a wider array of features than JVisualVM. In order to run YouKit Java Profiler you will need a temporary, 15 days trial license (unless you buy a permanent one...)

First we download the YourKit Java Profiler installer that best suits our needs from here. We install the dynamic analysis tool and then we start the application (on Windows using the menu Start -> Programs -> Yourkit Java Profiler x.y.z -> Yourkit Java Profiler, on MacOS via the newly created Desktop icon YourKit Java Profiler x.y.z). It might take a while to start.

From the application Home page we can run analyses for the demo application in the Example section. We go through the tab menu, exploring the available features of the profiler.

YourKit Java Profiler Eclipse Plugin

Install the YourKit Eclipse Plugin from the application Home page, via section Integration Wizards, where we choose Integrate with IDE..., and then, at Choose IDE to integrate with: you select your Eclipse version, fill in the field IDE installation directory with you Eclipse installation directory, and then you finalize the installation by clicking Install Plugin.

You then save profiler-project.zip and import it in Eclipse using the menu File -> Import -> General -> Existing Projects into Workspace...

Run the profiling tool on the imported project using the Eclipse plugin. Explore the various features it offers, and try to discover the possible issues your project under analysis might happen to have.

For more information, demos, etc., please check also the official documentation.