Java虚拟机和交换空间 [英] Java Virtual Machine and Swap Space

查看:320
本文介绍了Java虚拟机和交换空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

赞赏这里的任何专家都可以建议以下JVM和交换空间相关的查询.预先感谢

Apppreciate any expert here could advise for below JVM and swap space related queries. Thanks in advance

1)当JVM Java堆,Perm生成或本机堆中发生OutOfMemory时,操作系统是否将使用交换空间,对吗?还是将交换空间用于本机堆中的OutOfMemory?

1) Am I right that Operating System will use swap space when OutOfMemory occured in JVM Java Heap, Perm Generation or Native Heap ? Or swap space is used for OutOfMemory in Native Heap ?

2)我是否可以在JVM上配置本机堆大小是正确的,因为操作系统会在运行时将可用的RAM分配给JVM吗?

2) Am I right that Native heap size is not configurable at JVM, because OS will assign available RAM to JVM during runtime ?

3)我们如何为JVM启用交换空间,或者默认情况下为Unix和Window级别的所有进程启用交换空间?

3) How can we enable swap space for JVM, or swap space is enabled for all processes at Unix and Window level by default ?

4)了解交换空间会影响应用程序性能,这是为JVM禁用交换空间的最佳实践吗?如果没有,原因是什么?

4) Understand that swap space can affect application performance, is that best practice to disable swap space for JVM ? If not, what is the reason ?

5)如何在Unix和Window OS中如何禁用交换空间并更改特定JVM的交换空间大小,或者只能在OS级别上将其配置为适用于OS中的所有进程?

5) How can we disable swap space and change the swap space size for particular JVM in both Unix and Window OS, or it is only configurable at OS level which is applied to all processes in the OS ?

推荐答案

这里有很多问题...操作系统的确使用swap空间来创建所谓的virtual memory(显然比virtual memory大您可能拥有的RAM).默认情况下,通常处于启用状态,但是您需要进行检查.

There are a lot of questions here... Operating systems indeed use swap space to create the so called virtual memory (which is obviously bigger then the RAM you might have). It is usually enabled by default, but you need to check.

您不能指示JVM仅使用物理RAM AFAIK,但这将是OS本身而非JVM的限制(应回答5).

You can not instruct the JVM to use only the physical RAM AFAIK, but that would be a limitation of the OS itself and not JVM (this should answer 5).

您可以禁用交换(对于操作系统,也是,而不是JVM ,还是要禁用),但这不是一个好主意.操作系统内部运行着多个进程,每个进程都需要空间才能运行(有时某个时间可能会超出您的实际RAM).它确实会影响性能,但更糟的是-一些性能损失(我认为操作系统有很多事情要为您做得更好)或应用程序的死机? (这应该回答4).

You can disable swap (again for the OS, not JVM), but that is a bad idea. There are multiple processes that run inside the operating system and they each need space to run into (that at some point in time might exceed your actual RAM). It indeed affects performance, but what is worse - some performance penalties (I assume the OS has many things to make this better for you) or the death of the application? (this should answer 4).

关于(2),有两个参数控制您将拥有多少堆:Xmx-JVM进程将使用的最大堆.和Xms-初始堆.实际上,最近才有一个很好的讨论:

Regarding (2) there are two parameters that control how much heap you will have: Xmx - maximum heap that JVM process will use. And Xms - initial heap. Actually just recent there was a very good talk about this: here.

这篇关于Java虚拟机和交换空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆