You are on page 1of 15

Introduced in JDK6 update 7.

It is a visual tool which integrates functionality of


several JDK tools jps,jinfo,jstack,jmap,jconsole

Tool is useful to troubleshoot applications and to


monitor and improve the applications performance
With Java VisualVM track down memory leaks,
perform and monitor garbage collection

You can generate thread and heap dumps


and analyze them.

You can do lightweight CPU and Memory


Profiling

Attaches to local and remote process.


Lists All Java Processes of an User.

JINFO
C:\Program Files\Java\jdk1.7.0_79\bin>jinfo 3140

>Displays information about System properties and VMs Flags


details.
-flag option can be used to change the value of VM options
JSTACK Thread dump:

C:\Program Files\Java\jdk1.7.0_79\bin>jstack -l 3216


>jstack_threaddump

You can open the thread dump in any text editor and analyze.

Jmap : ( 3216 is the process id of my java program )

Memory Map of Java process can be generated.

Example:
C:\Program Files\Java\jdk1.7.0_79\bin>jmap -heap 3216 > jmap.out

You can open jmap.out in any text editor and see Heap Configuration &
Heap usage (Eden, Old, and Perm Gen) details.
JMAP -Heap Dump:
C:\Program Files\Java\jdk1.7.0_79\bin>jmap -dump:file heap_dump 3216

You cannot open the heap_dump(heap dump) in any of the text editor. Hence,
you have to use jhat.
JHAT :
C:\Program Files\Java\jdk1.7.0_79\bin>jhat.exe heap_dump
Go to your browser and type http://localhost:7000. You can analyze the
heap dump here.
OQL Object Query Language
Syntax of the select statement

select JavaScript-expression-to-select [ from


[instanceof] classname identifier [ where
JavaScript-boolean-expression-to-filter ] ]

Example:
select s from java.lang.String s where s.count
>= 100 (Refer to Saved Queries section)
Sampling means taking lots of thread dumps and analyzing stack traces.
This is usually faster, does not require runtime changes in your bytecode (which may break it),
but is also less accurate

Profiler works by instrumenting all of the methods of your code. so they "report"
whenever they are run. This is more accurate

Note:
If you wonder how come this MBeans&VisualGC tabs have started appearing,
it is that I have installed those plugins. Use Available Plugins tab or
Downloaded -> Add Plugins using the downloaded *.nbm file
Tool PROD Impact

Jconsole Almost None

Jvisual VM with No Profiler Almost None

Low Impact
Jstack
High Impact
Jmap

Jvisual VM with Profiler High Impact


Jstatd RMI - The jstatd tool is an RMI server application that
monitors for the creation and termination of instrumented
HotSpot Java virtual machines (JVMs) and provides a interface to
allow remote monitoring tools to attach to JVMs running on the
local host.
JMX Mbeans
JMX Authentication and Authorization
JMX SSL connection

TIP
For a workflow which has issues, take 3 4 thread stack dumps
during the workflow spaced out evenly and one heap dump at
the end, create a snapshot and save it to an app file for further
analysis.
Under certain scenarios, the heap dump generated might be
huge. However this will be very occasional and very beneficial for
analysis
2 Main Tools
Management Console (JMX)
Java Flight Recorder
Go ahead Explore

You might also like