0x1 错误
在导出 jvm 内存转储后使用mat工具进行分析,但是在执行 ParseHeapDump.sh 后提示如下错误:
cannot open display
尝试了很多办法,其中包括去掉所有参数直接执行此脚本,以及执行脚本实际调用的命令 MemoryAnalyzer,又或者更换 JDK 版本,都是报错的这个内容。在根据 mat 的相关内容进行搜索,也没有解决办法
最后通过 display 的关键字搜索出来了解决方案,如下:
export DISPLAY=:0
xset q
参考文档如下:
https://askubuntu.com/questions/476036/xset-unable-to-open-display
那么为什么会出现这种情况呢?相信弄清楚 DISPLAY=:0 就可以了,有一些难以理解的解释:
Explicitly setting DISPLAY=:0 is usually a way to access a machine's local display from outside the local session, such as over a remote access or from a cron job
:0
is usually the local display (i.e. the main display of the computer when you sit in front of it).
:1
is often used by services like SSH when you enable display forwarding and log into a remote computer.
It can also be modified by startup scripts which try to "fix" it. To find out whether this is happening, run
grep DISPLAY ~/.??*
.??*
is a trick to get all dot files without .. and . (parent and current folder).
If that doesn't print anything, check /etc/profile
,/etc/bash*
and /etc/bash*/*
in a similar manner.
I couldn't find a useful manual for xmacro but most X11 application support the option -d or -display to override $DISPLAY.
评论