import{_ as l,o as i,c as u,a as s,b as a,w as t,d as e,e as n,r as o}from"./app.391b0e4e.js";const r={},k=e(`
curl -O https://arthas.aliyun.com/math-game.jar
java -jar math-game.jar
math-game
\u662F\u4E00\u4E2A\u7B80\u5355\u7684\u7A0B\u5E8F\uFF0C\u6BCF\u9694\u4E00\u79D2\u751F\u6210\u4E00\u4E2A\u968F\u673A\u6570\uFF0C\u518D\u6267\u884C\u8D28\u56E0\u6570\u5206\u89E3\uFF0C\u5E76\u6253\u5370\u51FA\u5206\u89E3\u7ED3\u679C\u3002
\u5728\u547D\u4EE4\u884C\u4E0B\u9762\u6267\u884C\uFF08\u4F7F\u7528\u548C\u76EE\u6807\u8FDB\u7A0B\u4E00\u81F4\u7684\u7528\u6237\u542F\u52A8\uFF0C\u5426\u5219\u53EF\u80FD attach \u5931\u8D25\uFF09\uFF1A
curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar
admin
\u7528\u6237\u6765\u6267\u884C\uFF1Asudo su admin && java -jar arthas-boot.jar
\u6216 sudo -u admin -EH java -jar arthas-boot.jar
\u3002~/logs/arthas/
\u76EE\u5F55\u4E0B\u7684\u65E5\u5FD7\u3002java -jar arthas-boot.jar --repo-mirror aliyun --use-http
java -jar arthas-boot.jar -h
\u6253\u5370\u66F4\u591A\u53C2\u6570\u4FE1\u606F\u3002\u9009\u62E9\u5E94\u7528 java \u8FDB\u7A0B\uFF1A
$ $ java -jar arthas-boot.jar
* [1]: 35542
[2]: 71560 math-game.jar
math-game
\u8FDB\u7A0B\u662F\u7B2C 2 \u4E2A\uFF0C\u5219\u8F93\u5165 2\uFF0C\u518D\u8F93\u5165\u56DE\u8F66/enter
\u3002Arthas \u4F1A attach \u5230\u76EE\u6807\u8FDB\u7A0B\u4E0A\uFF0C\u5E76\u8F93\u51FA\u65E5\u5FD7\uFF1A
[INFO] Try to attach process 71560
[INFO] Attach process 71560 success.
[INFO] arthas-client connect 127.0.0.1 3658
,---. ,------. ,--------.,--. ,--. ,---. ,---.
/ O \\ | .--. ''--. .--'| '--' | / O \\ ' .-'
| .-. || '--'.' | | | .--. || .-. |\`. \`-.
| | | || |\\ \\ | | | | | || | | |.-' |
\`--' \`--'\`--' '--' \`--' \`--' \`--'\`--' \`--'\`-----'
wiki: https://arthas.aliyun.com/doc
version: 3.0.5.20181127201536
pid: 71560
time: 2018-11-28 19:16:24
$
$ dashboard
ID NAME GROUP PRIORI STATE %CPU TIME INTERRU DAEMON
17 pool-2-thread-1 system 5 WAITIN 67 0:0 false false
27 Timer-for-arthas-dashb system 10 RUNNAB 32 0:0 false true
11 AsyncAppender-Worker-a system 9 WAITIN 0 0:0 false true
9 Attach Listener system 9 RUNNAB 0 0:0 false true
3 Finalizer system 8 WAITIN 0 0:0 false true
2 Reference Handler system 10 WAITIN 0 0:0 false true
4 Signal Dispatcher system 9 RUNNAB 0 0:0 false true
26 as-command-execute-dae system 10 TIMED_ 0 0:0 false true
13 job-timeout system 9 TIMED_ 0 0:0 false true
1 main main 5 TIMED_ 0 0:0 false false
14 nioEventLoopGroup-2-1 system 10 RUNNAB 0 0:0 false false
18 nioEventLoopGroup-2-2 system 10 RUNNAB 0 0:0 false false
23 nioEventLoopGroup-2-3 system 10 RUNNAB 0 0:0 false false
15 nioEventLoopGroup-3-1 system 10 RUNNAB 0 0:0 false false
Memory used total max usage GC
heap 32M 155M 1820M 1.77% gc.ps_scavenge.count 4
ps_eden_space 14M 65M 672M 2.21% gc.ps_scavenge.time(m 166
ps_survivor_space 4M 5M 5M s)
ps_old_gen 12M 85M 1365M 0.91% gc.ps_marksweep.count 0
nonheap 20M 23M -1 gc.ps_marksweep.time( 0
code_cache 3M 5M 240M 1.32% ms)
Runtime
os.name Mac OS X
os.version 10.13.4
java.version 1.8.0_162
java.home /Library/Java/JavaVir
tualMachines/jdk1.8.0
_162.jdk/Contents/Hom
e/jre
math-game
\u8FDB\u7A0B\u7684 Main Classthread 1
\u4F1A\u6253\u5370\u7EBF\u7A0B ID 1 \u7684\u6808\uFF0C\u901A\u5E38\u662F main \u51FD\u6570\u7684\u7EBF\u7A0B\u3002
$ thread 1 | grep 'main('
at demo.MathGame.main(MathGame.java:17)
$ jad demo.MathGame
ClassLoader:
+-sun.misc.Launcher$AppClassLoader@3d4eac69
+-sun.misc.Launcher$ExtClassLoader@66350f69
Location:
/tmp/math-game.jar
/*
* Decompiled with CFR 0_132.
*/
package demo;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class MathGame {
private static Random random = new Random();
private int illegalArgumentCount = 0;
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
do {
game.run();
TimeUnit.SECONDS.sleep(1L);
} while (true);
}
public void run() throws InterruptedException {
try {
int number = random.nextInt();
List<Integer> primeFactors = this.primeFactors(number);
MathGame.print(number, primeFactors);
}
catch (Exception e) {
System.out.println(String.format("illegalArgumentCount:%3d, ", this.illegalArgumentCount) + e.getMessage());
}
}
public static void print(int number, List<Integer> primeFactors) {
StringBuffer sb = new StringBuffer("" + number + "=");
Iterator<Integer> iterator = primeFactors.iterator();
while (iterator.hasNext()) {
int factor = iterator.next();
sb.append(factor).append('*');
}
if (sb.charAt(sb.length() - 1) == '*') {
sb.deleteCharAt(sb.length() - 1);
}
System.out.println(sb);
}
public List<Integer> primeFactors(int number) {
if (number < 2) {
++this.illegalArgumentCount;
throw new IllegalArgumentException("number is: " + number + ", need >= 2");
}
ArrayList<Integer> result = new ArrayList<Integer>();
int i = 2;
while (i <= number) {
if (number % i == 0) {
result.add(i);
number /= i;
i = 2;
continue;
}
++i;
}
return result;
}
}
Affect(row-cnt:1) cost in 970 ms.
$ watch demo.MathGame primeFactors returnObj
Press Ctrl+C to abort.
Affect(class-cnt:1 , method-cnt:1) cost in 107 ms.
ts=2018-11-28 19:22:30; [cost=1.715367ms] result=null
ts=2018-11-28 19:22:31; [cost=0.185203ms] result=null
ts=2018-11-28 19:22:32; [cost=19.012416ms] result=@ArrayList[
@Integer[5],
@Integer[47],
@Integer[2675531],
]
ts=2018-11-28 19:22:33; [cost=0.311395ms] result=@ArrayList[
@Integer[2],
@Integer[5],
@Integer[317],
@Integer[503],
@Integer[887],
]
ts=2018-11-28 19:22:34; [cost=10.136007ms] result=@ArrayList[
@Integer[2],
@Integer[2],
@Integer[3],
@Integer[3],
@Integer[31],
@Integer[717593],
]
ts=2018-11-28 19:22:35; [cost=29.969732ms] result=@ArrayList[
@Integer[5],
@Integer[29],
@Integer[7651739],
]