FAQ¶
不在本列表里的问题,请到issue里搜索。 https://github.com/alibaba/arthas/issues
日志文件在哪里?¶
日志文件路径: ~/logs/arthas/arthas.log
Arthas attach之后对原进程性能有多大的影响¶
target process not responding or HotSpot VM not loaded¶
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
检查当前用户和目标java进程是否一致。如果不一致,则切换到同一用户。JVM只能attach同样用户下的java 进程。
尝试使用
jstack -l $pid
,如果进程没有反应,则说明进程可能假死,无法响应JVM attach信号。所以同样基于attach机制的Arthas无法工作。尝试使用jmap
heapdump后分析。尝试按quick-start里的方式attach math-game。
trace/watch等命令能否增强jdk里的类?¶
默认情况下会过滤掉java.
开头的类和被BootStrap ClassLoader
加载的类。可以通过参数开启。
options unsafe true
更多参考 options
通过 java.lang.instrument.Instrumentation#appendToBootstrapClassLoaderSearch append到
Bootstrap ClassLoader
的jar包需要开启unsafe。
Arthas能否跟踪 native 函数¶
不能。
方法同名过滤¶
同名方法过滤可以通过匹配表达式,可以使用表达式核心变量中所有变量作为已知条件,可以通过判断参数个数params.length ==1
, 参数类型params[0] instanceof java.lang.Integer
、返回值类型 returnObj instanceof java.util.List
等等一种或者多种组合进行过滤。
可以使用 -v
查看观察匹配表达式的执行结果 https://github.com/alibaba/arthas/issues/1348
watch demo.MathGame primeFactors '{params,returnObj,throwExp}' 'params.length >0 && returnObj instanceof java.util.List' -v
怎么watch、trace 构造函数 ?¶
watch demo.MathGame <init> '{params,returnObj,throwExp}' -v
java.lang.ClassFormatError: null、skywalking arthas 兼容使用¶
当出现这个错误日志java.lang.ClassFormatError: null
,通常情况下都是被其他字节码工具修改过与arthas修改字节码不兼容。
比如: 使用 skywalking V8.1.0 以下版本 无法trace、watch 被skywalking agent 增强过的类, V8.1.0 以上版本可以兼容使用,更多参考skywalking配置 skywalking compatible with other javaagent bytecode processing。
class redefinition failed: attempted to change the schema (add/remove fields)¶
参考: https://github.com/alibaba/arthas/issues/2165
Attach docker/k8s 里的 pid 为 1 的进程失败¶
参考: https://github.com/alibaba/arthas/issues/362#issuecomment-448185416
为什么下载了新版本的Arthas,连接的却是旧版本?¶
比如启动的 as.sh/arthas-boot.jar
版本是3.5.* 的,但是连接上之后,打印的arthas版本是 3.4.* 的。
可能是之前使用旧版本的arthas诊断过目标进程。可以先执行stop
停止掉旧版本的arthas,再重新使用新版本attach。