Why do we specify min and max heap memory when starting a jvm [duplicate]

时间:2022-09-29 07:26:41

Possible Duplicate:
Why does the (Sun) JVM have a fixed upper limit for memory usage (-Xmx)?

可能重复:为什么(Sun)JVM具有固定的内存使用上限(-Xmx)?

JVM should be like any other process and in a normal process, we don't specify max memory available to it and it is limited by say 4GB for 32-bit OS and so on.

JVM应该像任何其他进程一样,在正常的进程中,我们不指定可用的最大内存,并且对于32位操作系统限制为4GB,依此类推。

Then why in JVM it is not as simple as that and JVM can use that max memory for heap memory as well as native memory, as the need be.

那么为什么在JVM中它并不那么简单,JVM可以根据需要将最大内存用于堆内存以及本机内存。

Just a guess, Does it make things somehow more efficient, if JVM knows max heap memory available to it, upfront? and how does it work?

只是一个猜测,如果JVM预先知道可用的最大堆内存,它会以某种方式提高效率吗?它是如何工作的?

1 个解决方案

#1


0  

JVM can be used to sandbox a process. Memory needs to be restricted for an effective sandbox (to ensure it doesn't take all the memory - including that required by the OS).

JVM可用于沙盒化进程。需要限制内存以获得有效的沙箱(以确保它不占用所有内存 - 包括操作系统所需的内存)。

In this way, running Java applications is "safer", in that it is less likely to be able to screw up your computer.

通过这种方式,运行Java应用程序“更安全”,因为它不太可能搞砸你的计算机。

#1


0  

JVM can be used to sandbox a process. Memory needs to be restricted for an effective sandbox (to ensure it doesn't take all the memory - including that required by the OS).

JVM可用于沙盒化进程。需要限制内存以获得有效的沙箱(以确保它不占用所有内存 - 包括操作系统所需的内存)。

In this way, running Java applications is "safer", in that it is less likely to be able to screw up your computer.

通过这种方式,运行Java应用程序“更安全”,因为它不太可能搞砸你的计算机。