How to View Visual Gc in Visualvm

Visual GC in Java VisualVM via jstadt for remote Tomcat

Having done some more research and tests on our locale development environment i realized that we haven't had the right permissions on the production environment.
So i asked the admin to add jstatd to the sudoers list and voilà it works as expected:

sudo /usr/java/latest/bin/jstatd -J-Djava.security.policy=/home/empulse/tools.policy -J-Djava.rmi.server.hostname=[SERVER_IP]

How do we know which type of GC(young/full) is currently being executed in my Java Program using VisualVM or any other tool?

I am no VisualVM expert, so I do not know how to do this using. But I can provide you a couple of alternatives

JSTAT

You can see what kind of gc is being performed by using jstat

First we need to discover the PID of your Java running process. For this, we can use jps. In this example, a running Eclipse IDE.

jps
10156 org.eclipse.equinox.launcher_1.5.700.v20200207-2156.jar

Now use the following command jstat -gc 10156 1s

1s refers to the sampling interval. You can use whatever one that fits your needs.

This command outputs a table with a lot of columns, and I am finding it very hard to format (sorry), so please focus on these two ones

  • YGC: Number of young generation garbage collection (GC) events.
  • FGC: Number of full GC events.

Watching these two counters will give you a general idea of what type of collections are being performed.

JVM Flags

Besides, you can use a JVM flag

  • -Xlog:gc* for java 11
  • -XX:+PrintGCDetails for java 8

Which will print all GC details along the console: memory footprint before/after each collection, time spent, ergonomics ...

Output of this flag is somehow tricky to understand as it depends on your JVM implementation, selected GC, JVM flags ...

Remote application monitoring through Visual GC

Right, jstatd must be running on remote host, because VisualGC uses jvmstat and it does not use jmx.

What is the importance of the numbers inside the brackets in visual GC plugin?

See the visualgc tool page:

The title bar displays the name of the space and its maximum and current capacity in parenthesis followed by the current utilization of the space.

Note that you can also see the ratio between maximum and current capacity (=committed memory) in the “spaces” section, indicated by the brightness of the background grid (except for the survivor spaces, which may indicate that dynamic resizing is enabled).

The linked page also explains the other views.



Related Topics



Leave a reply



Submit