java tool常用命令分析
目錄
java命令
jps
沒新增option的時候,預設列出VM標示符號和簡單的class或jar名稱. [[email protected] ~]# jps 2306 jenkins.war 25801 Jps 25502 handler-processor-1.0-SNAPSHOT.jar -q :僅僅顯示VM 標示,不顯示jar,class, main引數等資訊. [[email protected] ~]# jps -q 25841 2306 25502 -m:輸出主函式傳入的引數. 下的hello 就是在執行程式時從命令列輸入的引數 [[email protected]
~]# jps -m 2306 jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20 25964 Jps -m 25502 handler-processor-1.0-SNAPSHOT.jar -l: 輸出應用程式主類完整package名稱或jar完整名稱. [[email protected] ~]# jps -l 2306 /usr/lib/jenkins/jenkins.war 25989 sun.tools.jps.Jps 25502 /home/hualala/handler-processor-1.0-SNAPSHOT.jar -v: 列出jvm引數, -Xms20m -Xmx50m是啟動程式指定的jvm引數 [[email protected] ~]# jps -v 2306 jenkins.war -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins 26025 Jps -Denv.class.path=.:/home/jdk/lib/dt.jar:/home/jdk/lib/tools.jar -Dapplication.home=/usr/java/jdk1.8.0_131 -Xms8m 25502 handler-processor-1.0-SNAPSHOT.jar -Xms4G -Xmx4G -XX:MaxGCPauseMillis=200 -Xss512K -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Duser.timezone=GMT+08 -Dfile.encoding=UTF-8 -Dspring.profiles.active=dohko -Dlogging.level.root=info
jmap
[[email protected] ~]# jmap -heap 25502
Attaching to process ID 25502, please wait… Debugger attached successfully. Server compiler detected. JVM version is 25.131-b11
using thread-local object allocation. Parallel GC with 4 thread(s)
Heap Configuration: MinHeapFreeRatio = 0 MaxHeapFreeRatio = 100 MaxHeapSize = 4294967296 (4096.0MB) NewSize = 1431306240 (1365.0MB) MaxNewSize = 1431306240 (1365.0MB) OldSize = 2863661056 (2731.0MB) NewRatio = 2 SurvivorRatio = 8 MetaspaceSize = 134217728 (128.0MB) CompressedClassSpaceSize = 1073741824 (1024.0MB) MaxMetaspaceSize = 134217728 (128.0MB) G1HeapRegionSize = 0 (0.0MB)
Heap Usage: PS Young Generation Eden Space: capacity = 938999808 (895.5MB) used = 938999808 (895.5MB) free = 0 (0.0MB) 100.0% used From Space: capacity = 247463936 (236.0MB) used = 0 (0.0MB) free = 247463936 (236.0MB) 0.0% used To Space: capacity = 244842496 (233.5MB) used = 0 (0.0MB) free = 244842496 (233.5MB) 0.0% used PS Old Generation capacity = 2863661056 (2731.0MB) used = 2863382888 (2730.734718322754MB) free = 278168 (0.26528167724609375MB) 99.99028628058417% used
18829 interned Strings occupying 1862872 bytes.
[[email protected] ~]# jmap -histo 25502 |head -30
num #instances #bytes class name
1: 35443818 1167325688 [C 2: 45933571 1102405704 java.lang.String 3: 3539491 849477840 com.hualala.supplychain.report.handler.processor.dao.entity.voucher.VoucherDetailEntity 4: 10618503 424740120 java.math.BigDecimal 5: 42723 159789752 [B 6: 24693 20599240 [Ljava.lang.Object; 7: 262144 6291456 org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptorNode 11: 40001 1280032 org.elasticsearch.common.bytes.BytesArray 12: 40000 960000 org.elasticsearch.common.text.Text 13: 10000 800000 org.elasticsearch.search.internal.InternalSearchHit 14: 1482 782496 io.netty.util.internal.shaded.org.jctools.queues.atomic.MpscAtomicArrayQueue 15: 36144 578304 java.lang.Object 16: 14259 570360 java.util.LinkedHashMapNode; 21: 10810 345920 java.util.HashMapNode; 23: 7946 317840 java.lang.ref.SoftReference 24: 11780 282720 java.util.IdentityHashMapEntry 25: 10000 240000 org.elasticsearch.index.Index 26: 10000 240000 org.elasticsearch.index.shard.ShardId 27: 10000 240000 org.elasticsearch.search.SearchShardTarget
[[email protected] ~]# jmap -histo:live 25502 |head -30
num #instances #bytes class name
1: 35465987 1168047200 [C 2: 45963026 1103112624 java.lang.String 3: 3541952 850068480 com.hualala.supplychain.report.handler.processor.dao.entity.voucher.VoucherDetailEntity 4: 10625886 425035440 java.math.BigDecimal 5: 42741 159791224 [B 6: 24675 20602120 [Ljava.lang.Object; 7: 262144 6291456 org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptorNode 11: 40001 1280032 org.elasticsearch.common.bytes.BytesArray 12: 40000 960000 org.elasticsearch.common.text.Text 13: 10000 800000 org.elasticsearch.search.internal.InternalSearchHit 14: 1482 782496 io.netty.util.internal.shaded.org.jctools.queues.atomic.MpscAtomicArrayQueue 15: 36257 580112 java.lang.Object 16: 14259 570360 java.util.LinkedHashMapNode; 21: 10810 345920 java.util.HashMapNode; 23: 7948 317920 java.lang.ref.SoftReference 24: 10000 240000 org.elasticsearch.index.Index 25: 10000 240000 org.elasticsearch.index.shard.ShardId 26: 10000 240000 org.elasticsearch.search.SearchShardTarget 27: 8472 203328 java.beans.MethodRef
[[email protected] ~]# jstat -gcutil 25502 1000 10
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT 0.00 0.00 96.87 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.87 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.87 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.87 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.87 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.87 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.87 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.87 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.88 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146 0.00 0.00 96.88 99.99 97.28 93.60 316 16.831 437 1208.314 1225.146