興國做網(wǎng)站網(wǎng)絡(luò)營銷方案的制定
jvm 運(yùn)行時(shí)數(shù)據(jù)區(qū)
jvm 運(yùn)行時(shí)數(shù)據(jù)區(qū)包括且不限于以下幾個(gè)部分:
- 堆(heap): 用于存儲對象實(shí)例和數(shù)組。堆內(nèi)存的分配和釋放由垃圾回收器進(jìn)行管理。
- 方法區(qū)(method area): 用于存儲類的信息、靜態(tài)變量、常量等。jdk 8 后方法區(qū)位于 metaspace。
- 虛擬機(jī)棧(vm stack): 用于存儲方法的局部變量、參數(shù)值等。
- 本地方法棧(native method stack): 用于存儲本地方法調(diào)用的相關(guān)信息。
- 程序計(jì)數(shù)器(program counter): 用于記錄當(dāng)前線程執(zhí)行的字節(jié)碼指令地址。
觀察 jvm 運(yùn)行時(shí)數(shù)據(jù)區(qū)內(nèi)存使用的命令
觀察 jvm 運(yùn)行時(shí)數(shù)據(jù)區(qū)內(nèi)存情況可以使用 jcmd 命令:
# 需要 JVM 參數(shù)配置 -XX:NativeMemoryTracking=summary 或 -XX:NativeMemoryTracking=detail
# 使用前需要先 su 切換到 pid 的用戶(top 中可看,一般 java 進(jìn)程的用戶是 tomcat),例如
su tomcat# 應(yīng)用啟動(dòng)后輸入
jcmd pid VM.native_memory summary
# 或
jcmd pid VM.native_memory detail# 例如
jcmd 385 VM.native_memory summary
輸出內(nèi)容:
輸出的 VM.native_memory 全部內(nèi)容
[tomcat@preparedocker-dep2-7f64d558f8-gfkmw default.qunar.com]$ jcmd 385 VM.native_memory summary
385:Native Memory Tracking:(Omitting categories weighting less than 1KB)Total: reserved=14696320KB, committed=13246344KB
- Java Heap (reserved=11534336KB, committed=11534336KB)(mmap: reserved=11534336KB, committed=11534336KB)- Class (reserved=1055872KB, committed=34688KB)(classes #41524)( instance classes #39223, array classes #2301)(malloc=7296KB #139986)(mmap: reserved=1048576KB, committed=27392KB)( Metadata: )( reserved=196608KB, committed=188544KB)( used=186864KB)( waste=1680KB =0.89%)( Class space:)( reserved=1048576KB, committed=27392KB)( used=25440KB)( waste=1952KB =7.13%)- Thread (reserved=574463KB, committed=245719KB)(thread #2115)(stack: reserved=568244KB, committed=239500KB)(malloc=3741KB #12726)(arena=2478KB #4229)- Code (reserved=262510KB, committed=170658KB)(malloc=14822KB #46616)(mmap: reserved=247688KB, committed=155836KB)- GC (reserved=506924KB, committed=506924KB)(malloc=45760KB #83524)(mmap: reserved=461164KB, committed=461164KB)- Compiler (reserved=16021KB, committed=16021KB)(malloc=15856KB #9536)(arena=165KB #5)- Internal (reserved=95580KB, committed=95576KB)(malloc=95540KB #150203)(mmap: reserved=40KB, committed=36KB)- Other (reserved=353690KB, committed=353690KB)(malloc=353690KB #1001)- Symbol (reserved=38658KB, committed=38658KB)(malloc=36572KB #993784)(arena=2086KB #1)- Native Memory Tracking (reserved=24133KB, committed=24133KB)(malloc=302KB #4295)(tracking overhead=23831KB)- Shared class space (reserved=12288KB, committed=12160KB)(mmap: reserved=12288KB, committed=12160KB)- Arena Chunk (reserved=12414KB, committed=12414KB)(malloc=12414KB)- Tracing (reserved=32KB, committed=32KB)(arena=32KB #1)- Logging (reserved=7KB, committed=7KB)(malloc=7KB #288)- Arguments (reserved=4KB, committed=4KB)(malloc=4KB #138)- Module (reserved=4051KB, committed=4051KB)(malloc=4051KB #14643)- Safepoint (reserved=8KB, committed=8KB)(mmap: reserved=8KB, committed=8KB)- Synchronization (reserved=872KB, committed=872KB)(malloc=872KB #7198)- Serviceability (reserved=2042KB, committed=2042KB)(malloc=2042KB #35392)- Metaspace (reserved=198597KB, committed=190533KB)(malloc=1989KB #2357)(mmap: reserved=196608KB, committed=188544KB)- String Deduplication (reserved=1KB, committed=1KB)(malloc=1KB #8)- Object Monitors (reserved=3817KB, committed=3817KB)(malloc=3817KB #18790)
命令權(quán)限問題
如執(zhí)行 jcmd pid VM.native_memory summary 命令后無輸出,需要通過 su 切換到 pid 的用戶(top 中可看,一般 java 進(jìn)程的用戶是 tomcat)