(轉)linux下jvm 參數調優

來源:互聯網
上載者:User

標籤:

1.基本概念。
JAVA_MEM_OPTS=" -server -Xmx2g -Xms2g -Xmn512m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseCompressedOops

-server 啟用能夠執行最佳化的編譯器。

-Xss 單個線程堆棧大小值。

-Xms 啟動應用時,JVM堆空間的初始大小值。

-Xmx 應用運行中,JVM堆空間的極限值。

-Xmn 堆空間的新生代空間大小。

-XX:PermSize永久儲存區的大小

2.VM效能診斷工具

基本工具:JPS ,JSTAT,JMAP

Jstat( “Java Virtual Machine statistics monitoring tool” )是JDK內建的一個輕量級小工具。主要對Java應用程式的資源和效能進行即時的命令列的監控,包括了對Heap size和記憶體回收狀況的監控。
文法結構如下:jstat [Options] vmid [interval] [count]
    Options -- 選項,我們一般使用 -gcutil 查看gc情況
    vmid    -- VM的進程號,即當前啟動並執行java進程號
    interval-- 間隔時間,單位為毫秒
    count   -- 列印次數,如果預設則列印無數次

[email protected](none):~# jstat -gcutil 595
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT  GCT  
  0.00   0.00  25.40  29.78  48.50      5    0.036     3    0.238    0.274

    S0  -- Heap上的 Survivor space 0 區已使用空間的百分比
    S1  -- Heap上的 Survivor space 1 區已使用空間的百分比
    E   -- Heap上的 Eden space 區已使用空間的百分比
    O   -- Heap上的 Old space 區已使用空間的百分比
    P   -- Perm space 區已使用空間的百分比
    YGC -- 從應用程式啟動到採樣時發生 Young GC 的次數
    YGCT-- 從應用程式啟動到採樣時 Young GC 所用的時間(單位秒)
    FGC -- 從應用程式啟動到採樣時發生 Full GC 的次數
    FGCT-- 從應用程式啟動到採樣時 Full GC 所用的時間(單位秒)
    GCT -- 從應用程式啟動到採樣時用於記憶體回收的總時間(單位秒)


jstat -gccapacity查看記憶體佔用情況
[[email protected] ~]$ jstat -gccapacity 10010

NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC      PGCMN    PGCMX     PGC       PC     YGC    FGC
65536.0 524288.0  65536.0 6528.0 6528.0  52480.0   196608.0  1572864.0   450572.0   450572.0  21248.0 131072.0  72900.0  72900.0  93842 16790

NGCMNMinimum new generation capacity (KB).
NGCMX Maximum new generation capacity (KB).
NGC Current new generation capacity (KB).
S0CCurrent survivor space 0 capacity (KB).
S1C Current survivor space 1 capacity (KB).
EC Current eden space capacity (KB).
OGCMNMinimum old generation capacity (KB).
OGCMX Maximum old generation capacity (KB).
OGC Current old generation capacity (KB).
OC Current old space capacity (KB).
PGCMNMinimum permanent generation capacity (KB).
PGCMX Maximum Permanent generation capacity (KB).
PGC Current Permanent generation capacity (KB).
PC Current Permanent space capacity (KB).
YGCNumber of Young generation GC Events.
FGC Number of Full GC Events.

jmap
jmap 是一個可以輸出所有記憶體中對象的工具,甚至可以將VM 中的heap,以二進位輸出成文本。
使用方法
jmap -histo pid>a.log可以將其儲存到文本中去,在一段時間後,使用文本對比工具,可以對比出GC回收了哪些對象。
jmap -dump:format=b,file=f1 PID可以將該PID進程的記憶體heap輸出出來到f1檔案裡。

整合工具: JConsole,jvisualvm

典型效能故障分析

2.vmstat

(轉)linux下jvm 參數調優

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.