java 如何使用 jstat 获取堆使用情况?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43735962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get heap usage using jstat?
提问by X. Wo Satuk
I'm running jstat -gc (from OpenJDK):
我正在运行 jstat -gc(来自 OpenJDK):
# jstat -gc 1
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
287744.0 290304.0 88368.6 0.0 1469440.0 787186.5 2162176.0 1805969.7 945432.0 923880.4 136576.0 133284.0 268 32.797 21 30.089 62.886
How to read:
如何阅读:
used heap
heap size
max heap
用过的堆
堆大小
最大堆
from this output, just like shown by VisualVM?
从这个输出,就像 VisualVM 显示的一样?
回答by S. D.
See https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.htmlfor general reference.
有关一般参考,请参阅https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html。
Current heap size would be the sum of all the fields that end with "C" - S0C, S1C, EC, OC (except for Metaspace which is the fields that start with "M")
当前堆大小将是所有以“C”结尾的字段的总和 - S0C、S1C、EC、OC(元空间除外,它是以“M”开头的字段)
Used heap would be the sum of all the fields that end with "U" - S0U, S1U, EU, OU (again, except metaspace).
使用的堆将以“U”结尾的所有字段的总和 - S0U、S1U、EU、OU(同样,元空间除外)。
Note that the "C" values (current) are greater than or equal to "U" values (actually used).
请注意,“C”值(当前)大于或等于“U”值(实际使用)。
To get maximum values run jstat with the -gccapacity flag and add up all the fields that end with "MX" (NGCMX, OGCMX, ... except for MCMX which is metaspace).
要获得最大值,请使用 -gccapacity 标志运行 jstat 并将所有以“MX”结尾的字段相加(NGCMX、OGCMX、...除了元空间的 MCMX)。