Basics of JVM

1, jvm role

(1) Translation java code for different operating systems.

(2) instructions explained.

 

2, jvm runtime data area

 

 

 

 

 

Anti translation system command:

javap -c -v TestCase.class 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 jvisualvm

 

 

 

 

 

 

 

 

 

jstack (see jvm thread running, if there is deadlock and so forth)
jinfo: output and can modify opts java process running. 
jps: Similar to ps on unix, used to display the local java process, you can view local running several java program, and show them the process ID. 
jstat: a strong monitoring VM memory tool. It can be used to monitor a variety of non-heap and stack size and memory usage in VM memory. 
jmap: prints out some java process (using pid) all 'objects' in the memory situation (such as: produce those objects, and their number). 
jconsole: a monitoring tool java GUI, various data can be displayed in graphical forms. Monitoring the remote server may be connected through a remote VM.

 

详细:在使用这些工具前,先用JPS命令获取当前的每个JVM进程号,然后选择要查看的JVM。
jstat工具特别强大,有众多的可选项,详细查看堆内各个部分的使用量,以及加载类的数量。使用时,需加上查看进程的进程id,和所选参数。以下详细介绍各个参数的意义。
jstat -class pid:显示加载class的数量,及所占空间等信息。
jstat -compiler pid:显示VM实时编译的数量等信息。
jstat -gc pid:可以显示gc的信息,查看gc的次数,及时间。其中最后五项,分别是young gc的次数,young gc的时间,full gc的次数,full gc的时间,gc的总时间。
jstat -gccapacity:可以显示,VM内存中三代(young,old,perm)对象的使用和占用大小,如:PGCMN显示的是最小perm的内存使用量,PGCMX显示的是perm的内存最大使用量,PGC是当前新生成的perm内存占用量,PC是但前perm内存占用量。其他的可以根据这个类推, OC是old内纯的占用量。
jstat -gcnew pid:new对象的信息。
jstat -gcnewcapacity pid:new对象的信息及其占用量。
jstat -gcold pid:old对象的信息。
jstat -gcoldcapacity pid:old对象的信息及其占用量。
jstat -gcpermcapacity pid: perm对象的信息及其占用量。
jstat -util pid:统计gc信息统计。
jstat -printcompilation pid:当前VM执行的信息。
除了以上一个参数外,还可以同时加上 两个数字,如:jstat -printcompilation 3024 250 6是每250毫秒打印一次,一共打印6次,还可以加上-h3每三行显示一下标题。

 

 

jmap是一个可以输出所有内存中对象的工具,甚至可以将VM 中的heap,以二进制输出成文本。
命令:jmap -dump:format=b,file=heap.bin <pid>
file:保存路径及文件名
pid:进程编号
•jmap -histo:live pid| less :堆中活动的对象以及大小
•jmap -heap pid : 查看堆的使用状况信息

jinfo:的用处比较简单,就是能输出并修改运行时的java进程的运行参数。用法是jinfo -opt pid 如:查看2788的MaxPerm大小可以用 jinfo -flag MaxPermSize 2788。

jconsole是一个用java写的GUI程序,用来监控VM,并可监控远程的VM,非常易用,而且功能非常强。使用方法:命令行里打 jconsole,选则进程就可以了。
JConsole中关于内存分区的说明。

Eden Space (heap): 内存最初从这个线程池分配给大部分对象。
Survivor Space (heap):用于保存在eden space内存池中经过垃圾回收后没有被回收的对象。
Tenured Generation (heap):用于保持已经在 survivor space内存池中存在了一段时间的对象。
Permanent Generation (non-heap): 保存虚拟机自己的静态(refective)数据,例如类(class)和方法(method)对象。Java虚拟机共享这些类数据。这个区域被分割为只读的和只写的,
Code Cache (non-heap):HotSpot Java虚拟机包括一个用于编译和保存本地代码(native code)的内存,叫做“代码缓存区”(code cache)

•jstack ( 查看jvm线程运行状态,是否有死锁现象等等信息) : jstack pid : thread dump
•jstat -gcutil pid 1000 100 : 1000ms统计一次gc情况统计100次;

Guess you like

Origin www.cnblogs.com/shmily2018/p/11502497.html
JVM
JVM