jdk(1.8)命令行工具(二)

2.3 jinfo:java配置信息工具

  jinfo(Configuration Info for Java)的作用是实时的查看和调整虚拟机的各项参数。使用jps -v 可以查看虚拟机启动时显示指定的参数列表,但如果想知道未被显示指定的参数的系统默认值,就只能使用jinfo -flag选项进行查看(jdk1.6以上也可以使用 java -XX:+PrintFlagsFinal进行查看)

  命令格式:

    jinfo [option] pid

            

jinfo工具主要选项
选项  作用
-flags  查看jvm参数
 -flag  查看或修改(部分)某个jvm参数
-sysprops  查看系统参数
 -h  查看jinfo命令帮助

2.4 jmap(Java内存映像工具)

  jmap(Memery Map for JAVA)主要用于生成堆转储快照(一般称为heapdump或dump文件),还可以用来查询finalize 执行队列、java堆和永久代的详细信息,如空间使用率、当前使用的是那种收集器等

  命令格式:

    jmap [option] vmid

        

jmap工具主要选项
    选项  作用
 -dump  生成java堆转储快照。格式为:-dump [live,] format=b,file=<filename>,其实live子参数说明是否只dump出存活的对象
-clstats  显示类加载器统计信息
-heap  显示java堆详细信息,如使用哪种回收器、参数配置、分代状况等。只在Linux/Solari平台下有效
-histo  显示堆中对象统计信息,包括类、实例数量、合计容量
-F  当虚拟机进程对-dump没有响应时,可使用这个选项强制生成dump快照。只在Linux/Solari平台下有效

    

各工具选项输出内容详解

-dump:  

  jmap -dump:live,format=b,file=./temp.hprof  22963  (生成dump文件,dump文件的分析后续更新)

-clstats:

  jamp -clstats 22963

  

Attaching to process ID 22963, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.11-b03
finding class loader instances ..done.
computing per loader stat ..done.
please wait.. computing liveness.liveness analysis may be inaccurate ...
class_loader    classes bytes   parent_loader   alive?  type

<bootstrap>     844     1449946   null          live    <internal>
0x00000006c8512770      712     1301624 0x00000006c85127c8      dead    sun/misc/Launcher$AppClassLoader@0x00000007c0038320
0x00000006c931c380      1       1471    0x00000006c8512770      dead    sun/reflect/DelegatingClassLoader@0x00000007c0009870
0x00000006c85127c8      0       0         null          dead    sun/misc/Launcher$ExtClassLoader@0x00000007c002d320

total = 4       1557    2753041     N/A         alive=1, dead=3     N/A    

  

 

-heap:

  jmap -heap 22963

Attaching to process ID 22963, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.11-b03

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 4156555264 (3964.0MB)
   NewSize                  = 1572864 (1.5MB)
   MaxNewSize               = 1385168896 (1321.0MB)
   OldSize                  = 258473984 (246.5MB)
   NewRatio                 = 2 -------------------------------(年轻代(包括Eden和两个Survivor区)与年老代的比值(除去持久代))
   SurvivorRatio            = 8  -------------------------------(Eden区与Survivor区的大小比值) 
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:    ------------------------------------------(伊甸区)
   capacity = 5242880 (5.0MB)-------------------------(容量) 
   used     = 0 (0.0MB)----------------------------------(已使用)
   free     = 5242880 (5.0MB) --------------------------(空闲)   
   0.0% used---------------------------------------------(使用率)
From Space:
   capacity = 18874368 (18.0MB)
   used     = 0 (0.0MB)
   free     = 18874368 (18.0MB)
   0.0% used
To Space:
   capacity = 19398656 (18.5MB)
   used     = 0 (0.0MB)
   free     = 19398656 (18.5MB)
   0.0% used
PS Old Generation
   capacity = 383778816 (366.0MB)
   used     = 372174176 (354.9329528808594MB)
   free     = 11604640 (11.067047119140625MB)
   96.97621663411458% used

1823 interned Strings occupying 151824 bytes.

  

-histo:

  jmap -histo 22963 | head -n 30

 num     #instances         #bytes  class name
----------------------------------------------
   1:          4252      245748768  [B
   2:         28460       68723560  [Ljava.lang.Object;
   3:          7529       30808288  [Ljava.nio.channels.SelectionKey;
   4:         18018       11819808  io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueue
   5:          7493        4315968  io.netty.util.internal.shaded.org.jctools.queues.MpscChunkedArrayQueue
   6:          1896        1271040  [Lio.netty.util.Recycler$DefaultHandle;
   7:          4106        1074784  [I
   8:           213         847568  [Ljava.nio.ByteBuffer;
   9:         15050         722400  java.util.HashMap
  10:         10363         719672  [C
  11:          3746         539424  io.netty.channel.nio.NioEventLoop
  12:         16632         532224  io.netty.buffer.PoolThreadCache$SubPageMemoryRegionCache
  13:          3875         443784  [J
  14:          3746         269712  sun.nio.ch.EPollArrayWrapper
  15:          3746         269712  sun.nio.ch.EPollSelectorImpl
  16:          4230         236880  java.util.LinkedHashMap
  17:          9840         236160  java.lang.String
  18:           477         183168  io.netty.util.concurrent.FastThreadLocalThread
  19:          1937         156488  [Ljava.util.HashMap$Node;
  20:          1499         156072  java.lang.Class
  21:          9685         154960  java.lang.Object
  22:          3788         151520  java.util.LinkedHashMap$Entry
  23:          4215         134880  io.netty.util.concurrent.DefaultPromise
  24:          3154         126160  java.util.WeakHashMap$Entry
  25:          3749         119968  sun.nio.ch.AllocatedNativeObject
  26:          7497         119952  java.util.concurrent.atomic.AtomicBoolean
  27:          7496         119936  java.util.HashSet

  

 

 

posted @ 2018-05-28 21:07  孤*狼  阅读(950)  评论(0编辑  收藏  举报