在Linux下,命令和Windows下一樣,用root用戶輸入以下命令:
jmap -dump:format=b,file=/filepath/heap.bin pid
結果報錯:
Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
上網搜了一下,是因為目標進程是另一個用戶啟動的,所以用root用戶就jmap不了,換啟動進程的那個用戶就行了
第2次如果再次用root用戶輸入這個命令,會報另一個錯誤:
well-known file is not secure
原因也是一樣,目標進程是哪個用戶啟動的,就要用哪個用戶來執行jmap命令 。