在CentOS上匯出JVM記憶體資訊,centos匯出jvm記憶體

來源:互聯網
上載者:User

在CentOS上匯出JVM記憶體資訊,centos匯出jvm記憶體
首先看下Tomcat的進程Id:

[root@iZ25Z ~]# ps aux | grep javawww       2111  4.0 23.5 1637648 452756 ?      Sl   10:12   4:35 /usr/java/jdk1.7.0_80/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties ...  
可以看到Tomcat的進程Id是2111, 然後用JDK內建工具jmap來匯出整個JVM 中記憶體資訊:
# jmap -dump:format=b,file=檔案名稱  [pid]jmap -dump:format=b,file=mm.hprof 2111
然而我們卻得到了這個提示:
jmap -dump:format=b,file=mm.hprof 21112111: Unable to open socket file: target process not responding or HotSpot VM not loadedThe -F option can be used when the target process is not responding
這是因為我是以root這個使用者執行的這個語句,但我的tomcat進程是以www使用者啟動並執行(用 ps aux | grep java 便能看到)。我們可以在機器上找到 /tmp/hsperfdata_$USER/$PID一個這樣的檔案,當我們執行jmap出現上述資訊時,先檢查執行該命令的使用者是否和hsperfdata_$USER這個檔案所屬的使用者一致,如果不一致,切換成一致再執行即可,或者根據提示,直接加個 -F 參數即可:
jmap -F-dump:format=b,file=mm.hprof 2111
man page對這個選項的說明是:
-F Force. Use with jmap -dump or jmap -histo option if the pid does not respond. The live suboption is not supported in this mode.
轉載請註明出處,本文地址:http://www.iiilab.com/article/6

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.