简体   繁体   English

哪些JVM选项具有优先权?

[英]Which JVM options take priority?

I followed this answer in order to increase the amount of memory that is allocated to the JVM on a system-wide basis. 我遵循此答案是为了增加在系统范围内分配给JVM的内存量。 It seems to work as advertised as far as getting the setting to the Java process. 就将设置传递到Java进程而言,它似乎可以做为广告。

However, the Java process that I want to increase the memory allocation for is actually being spawned by an opaque third-party process that specifies its own memory options when it creates the Java process (and which provides no configuration of the options that it passes, hence the need for the system-wide setting). 但是,我要增加内存分配的Java进程实际上是由一个不透明的第三方进程生成的,该第三方进程在创建Java进程时指定了自己的内存选项(并且不提供所传递选项的配置,因此需要系统范围的设置)。

So what happens is that both settings get passed to the Java process. 因此,发生的情况是两个设置都传递给了Java进程。 Or at least, that's what appears to happen when I use the approach described here to view the JVM arguments. 或者至少,当我使用此处描述方法查看JVM参数时,似乎会发生这种情况。 I get something like: 我得到类似的东西:

在此处输入图片说明

Is there some precedence order that dictates which setting is used when the same option is specified multiple times (and that guarantees that the same setting will always be selected)? 是否有一些优先顺序规定了多次指定同一选项时使用的设置(并保证始终选择同一设置)?

Or is there some other way to check to see which settings are actually being applied? 还是有其他方法可以查看实际应用了哪些设置?

to check you can do this 检查你可以做到这一点

-Xms128m
-Xmx256m
-Xmx2g

and then 接着

// allocate 256m
byte[] array = new byte[ 256 * 1024 * 1024 ];
System.out.println(runtime.totalMemory());

if its first option that gets picked up it will OOM, otherwise it will proceed and it will show you total memory as > 256m 如果选择了它的第一个选项,它将是OOM,否则它将继续进行,并且总内存为> 256m

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

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