最近一段时间常用JDK自带工具jmap和jstack来dump JVM heap和JVM 线程栈的log来分析问题,执行这两个命令当时让我最摸不着头脑的就是碰到这个问题:well-known file is not secureapi
eg:app
上网google了一把,在stackoverflow上找到答案:http://stackoverflow.com/questions/9100149/jstack-well-known-file-is-not-secure?rq=1,大概意思是:工具
咱们能够在机器上找到 /tmp/hsperfdata_$USER/$PID一个这样的文件,当咱们执行jmap或者jstack出现上叙信息时,先检查执行该命令的用户是否和hsperfdata_$USER这个文件所属的用户一致,若是不一致,切换至成一致再执行便可。google
获取当前堆快照线程
jmap -dump:format=b,file=./heap.hprof 20344(pid)
20344: well-known file is not secureorm
sudo -u app-cfg-api jmap -dump:format=b,file=./heap.hprof 20344
Dumping heap to /tmp/hsperfdata_app-cfg-api/heap.hprof ...
Heap dump file createdio