2015-11-20 33 views
3

我需要監視JVM Metaspace使用情況。你能幫助我請下列事情嗎?我需要監視JVM Metaspace使用情況

如何找到使用的元空間大小?

使用以下命令我發現maxmetaspace和最小元空間:

jmap -heap `ps -ef | grep java | grep -v grep | awk '{print $2}'` | grep -i Metaspace 

MetaspaceSize = 21807104(20.796875MB)
MaxMetaspaceSize = 1073741824(1024.0MB)

但如何我能找到現在使用的內存的價值嗎?

+0

不那麼肯定。但是,我想你可以在運行java命令時通過設置標誌'-verbose:gc'來獲得它。 –

+0

這樣? jmap -heap'ps -ef | grep java | grep -v grep | AWK「{打印$ 2}」'-verbose:GC是不工作...附加到核心-verbose:從可執行5270 GC,請稍候... 錯誤連接到核心文件:無法打開二進制文件 –

+0

你是什麼意思詳細:gc不工作?我會修復第一個 –

回答

1

可以使用MemoryPoolMXBean

List<MemoryPoolMXBean> memPool = ManagementFactory.getMemoryPoolMXBeans(); 
for (MemoryPoolMXBean p : memPool) 
{ 
    if ("Metaspace".equals(p.getName()) 
    { 
     ... here you have the memory pool mx bean with information about he metaspace 
    } 
} 
+0

,我怎樣才能在linux命令中做到這一點?我想要的是找到一個linux命令誰將返回現在使用的metaspace的值 –