錯誤現象
使用 HSDB (HotSpot Serviceability Agent) 執行 scanoops 命令掃描堆對象時,報錯:Windbg Error: ReadVirtual failed!。環境:JDK 1.8.0_20,Windows 8.1。
可能原因
- Windbg 版本與 JDK 版本不匹配,導致調試接口調用失敗。
- 目標進程權限不足(需管理員權限附加)。
- HSDB 內部使用的 SA (Serviceability Agent) 在較新 Windows 版本上兼容性問題。
建議排查步驟
- 以管理員身份運行 HSDB / Windbg。
- 確認 Windbg 版本(建議使用 Windows SDK 10 自帶版本)。
- 嘗試使用
jhsdb (JDK 9+ 內置) 替代 HSDB,功能更完善。
- 參考 CSDN 討論帖:HSDB Windbg ReadVirtual failed 解決方案
替代工具
推薦使用 JVisualVM、JConsole、Arthas (阿里開源) 進行線上 JVM 診斷,無需 Windbg 內核調試,體驗更佳。