Use VisualVM tool

First, plug-in installation

 

jvisualvm is released together with the jdk jvm diagnostic tools, many functions can be extended via plug-ins, plug-in extensions also jvisualvm the essence.
Open the tool, the menu "Tools" -> "plug-in" Development following dialog:
Write pictures described here
select the available plug-in installed plug tab, the need to use block Bowen two plug as shown in the figure above.

Second, adjusting the speed class loading IDEA

Present time measuring section uses pluginsVisual GC。

IDEA在启动时,由于加载很多的类,占用了较长的时间,其实在加载这些类时,还有很重要的一步就是验证这些加载的类。平时我们都是在组内开发工程,可以认为这些加载的编译代码是可靠的,不需要在加载的视乎再进行字节码验证。我们可以通过参数-Xverify:none禁止字节码验证,加快IDEA的启动过程。
这个参数要加载IDEA的配置文件中,一般情况下,配置文件在个人目录下:
这里写图片描述
修改后的配置文件如下:

-Xms512m -Xmx1500m -XX:ReservedCodeCacheSize=240m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -XX:MaxJavaStackTraceDepth=-1 -agentlib:yjpagent64=probe_disable=*,disablealloc,disabletracing,onlylocal,disableexceptiontelemetry,delay=10000,sessionname=IntelliJIdea2017.2 -Xverify:none

这些参数也可在jvisualvm的概述面板下看到:
这里写图片描述

通过添加参数-Xverify:none配置后,类加载速度提高30s以上。可以通过visual vm插件面板查看:
这里写图片描述

根据visual vm中面板的显示内容,我们还可以调整jvm堆的设置,尽情探索吧~

Three: remote monitoring of jvm

1. The remote monitoring tomcat, needs to be disposed at a remote JMX tomcat, as follows:

2, JMX way
JMX is the way we monitor application servers (JBoss) commonly used method, using JMX monitoring function is not supported by Visual GC.

We often need to do to develop our various software testing, software usage of system resources is essential, there are multiple monitoring tools, especially compared JProfiler is very large memory consumption of system resources, JDK1. 6 start comes with VisualVM is a good monitoring tool.
jvisualvm.exe this tool in the JAVA_HOME \ bin \ directory, double-click the file you can see a more intuitive interface

jvisualvm.exe this tool in the JAVA_HOME \ bin \ directory, double-click the file you can see a more intuitive interface

 
Applications from the left side of the tree can be known, not only can monitor the operation of the local JVM, JVM can also monitor the operation on the remote machine.
Local monitoring: Just open a JAVA program will be automatically added to local monitoring.

因为本地监控无需配置, 所以这里主要介绍监控远程JVM
要进行远程监控, 本机的VisualVM就必须和远程的JVM要进行通信, Visualvm目前支持两种remote connection方式.
分别是jstatd和JMX方式: 这里我主要介绍的是通过JMX方式.

通过JMX连接远程机器, 需要经过下面的配置:
1. 修改远程机器JDK配置文件 (我这里远程机器是linux).
   a.进入JAVA_HOME\jre\lib\management\目录
   b.拷贝jmxremote.password.template这个文件到当前目录, 并改名为jmxremote.password
     c.打开jmxremote.password文件,去掉 # monitorRole  QED 和 # controlRole  R&D 这两行前面的注释符号

2. 修改远程机器上需要被监控的程序的配置文件 (我这里是监控Tomcat容器内部署的应用).
   a.进入TOMCAT_HOME\bin目录
     b.打开catalina.sh文件,加入如下信息:
        

JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=192.168.0.237
                                                     -Dcom.sun.management.jmxremote.port=18999
                                                     -Dcom.sun.management.jmxremote.ssl=false 
                                                     -Dcom.sun.management.jmxremote.authenticate=false"

 


   c.重启Tomcat服务.

如果是java server,则在脚本中加入 -Dcom.sun.management.jmxremote.port=10004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=192.168.136.21 即可。


3. Client Configuration VisualVM (clients I use the WinXP).
     A. Direct anti-click Remote, Remote Host ... to select the Add
     b. In the pop-up interface, enter the IP address of the remote machine (192.168.0.237), this IP address will be added to the Remote node under.
     C. trans-click the IP address, select Add JMX connection, in the pop-up interface input port number (18999) just configured, the connection will be added to this IP node.
     D anti button click on this link and select Open.

At this point you can see the monitor interface, we can see the CPU information, memory information, the number of load class statistics, thread information from the interface.

Original link: https: //blog.csdn.net/wzyzzu/article/details/ 50,380,511

 

Guess you like

Origin www.cnblogs.com/yangzhixue/p/11990441.html