Java Reference
In-Depth Information
Figure 11-5. VisualVM's Sampler tab
In both tabs, you're presented with the same screen, which includes CPU and Memory buttons as
well as a Stop button. To begin sampling either CPU execution by method or memory footprint by class,
click the appropriate button. The tables update periodically with the current state of the VM VisualVM is
studying. The difference between the two tabs is that the Profiler tab can execute garbage collections
and save the data it has collected, but the sampler tab can't.
VisualVM is a powerful and extendable tool. Many plug-ins are available to extend the feature set
provided out of the box. You can add things like the ability to view the stack trace of currently executing
threads with the Thread Inspector plug-in, visual garbage collection with the Visual GC plug-in, and
access to MBeans via the MBean browser, to extend VisualVM's already powerful suite of tools.
Now that you have an idea of what Oracle's VisualVM can do, let's see how you can use it to profile
Spring Batch applications.
Profiling Spring Batch Applications
When you profile your applications, you're typically looking at one of two things: how hard the CPU is
working and where, and how much memory is being used and on what. The first questions, how hard
the CPU is working and where, relate to what your CPU is working on. Is your job computationally
difficult? Is your CPU using a lot of its effort in places other than your business logic—for example, is it
spending more time working on parsing files than actually doing the calculations you want it to? The
second set of questions revolves around memory. Are you using most if not all of the available memory?
If so, what is taking up all the memory? Do you have a Hibernate object that isn't lazily loading a
collection, which is causing the issues? This section looks at how to see where resources are being used
in your Spring Batch applications.
Search WWH ::

Custom Search