简体   繁体   English

XMX和GC日志数据不匹配

[英]Xmx and gc log data not matching

I ran a test program (adds list with string in a infinite loop) using below jvm arguments 我使用以下jvm参数运行了一个测试程序(在无限循环中添加带有字符串的列表)

java -XX:+PrintGCDetails -Xloggc:gc.log Test -Xmx=1k -Xms=1k

and got the below exception 并得到以下异常

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

In the gc log i see the below collection as the last entry 在gc日志中,我将以下集合作为最后一个条目

11.242: [Full GC (Allocation Failure) [PSYoungGen: 0K->0K(92160K)] [ParOldGen: 274084K->274072K(371712K)] 274084K->274072K(**463872K**), [Metaspace: 2522K->2522K(1056768K)], 3.0296130 secs] [Times: user=3.28 sys=0.00, real=3.02 secs] 

If min and max is 1k how come the heap memory available is showing as 463872K ? 如果min和max为1k,那么可用的堆内存如何显示为463872K

Plus in the oracle site 在Oracle站点中加号

https://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/jrdocs/refman/optionX.html https://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/jrdocs/refman/optionX.html

I see a note , 我看到一个字条,

Note: -Xmx does not limit the total amount of memory that the JVM can use. 注意: -Xmx不会限制JVM可以使用的内存总量。

What does this means? 这是什么意思?

You have specified Xmx and Xms parameters after the name of your class. 您已经在类名称之后指定了XmxXms参数。 Thus java executable command interprets them as parameters to your class, not as options to configure JVM. 因此, java可执行命令将它们解释为类的参数,而不是配置JVM的选项。 The correct way would be: 正确的方法是:

java -Xmx1k -Xms1k -XX:+PrintGCDetails -Xloggc:gc.log Test

Also note, that the correct format is -Xmx1k , not -Xmx=1k . 另请注意,正确的格式是-Xmx1k ,而不是-Xmx=1k

But please not, that JVM will not start with such low value of Xms. 但是请不要,JVM不会以如此低的Xms开头。

@Nikem responded correctly and I would not like to respond to that part of the question. @Nikem正确回答了,我不想回答问题的这一部分。 However, I would like to add something to your second question - 但是,我想在您的第二个问题中添加一些内容-

Note: -Xmx does not limit the total amount of memory that the JVM can use. 注意:-Xmx不会限制JVM可以使用的内存总量。 What does this imply? 这意味着什么?

-Xmx only limits the memory available for consumption by your application heap. -Xmx仅限制可用于应用程序堆使用的内存。

But JVM will need memory space for PermGen and stack sizes which are not accounted for with the -Xmx parameter. 但是,JVM将需要PermGen的内存空间和堆栈大小,而-Xmx参数未考虑这些大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM