首页 技术 正文
技术 2022年11月8日
0 收藏 838 点赞 1,565 浏览 2199 个字

本机为64位操作系统,64位jdk,win10。

修改C:\Program Files\Java\jre8\lib\amd64\jvm.cfg无效。

我的文件的内容为:

jdk的server模式修改无效(关于client和server模式)

原因参考如下:

http://bluethinking.iteye.com/blog/2166857

http://ryxxlong.iteye.com/blog/1696537

两种模式下的堆大小:

http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html#sthref32

自己的渣渣水平翻译下:

Default Heap Size

Unless the initial and maximum heap sizes are specified on the command line, they are calculated based on the amount of memory on the machine.

默认堆大小是基于机器的内存,除非最小堆内存和最大堆内存容量在命令行被显式指定。

Client JVM Default Initial and Maximum Heap Sizes

The default maximum heap size is half of the physical memory up to a physical memory size of 192 megabytes (MB) and otherwise one fourth of the physical memory up to a physical memory size of 1 gigabyte (GB).

默认的最大堆内存大小是物理内存(最多达192M)的一半;如果内存大于或等于1GB,则取其1/4.

For example, if your computer has 128 MB of physical memory, then the maximum heap size is 64 MB, and greater than or equal to 1 GB of physical memory results in a maximum heap size of 256 MB.

举例,如果你的电脑有128M物理内存,那么最大堆大小是64M;如果物理内存大于等于1G,则最大堆大小是256M.

The maximum heap size is not actually used by the JVM unless your program creates enough objects to require it. A much smaller amount, called the initial heap size, is allocated during JVM initialization. This amount is at least 8 MB and otherwise 1/64th of physical memory up to a physical memory size of 1 GB.

最大堆大小不会被JVM实际使用,除非你的程序创建了足够多的对象去获取对应大小的内存。在JVM初始化时,最小堆内存容量的内存被分配。这个容量最小为8M,或者物理内存(最大1G)的64分之1。

The maximum amount of space allocated to the young generation is one third of the total heap size.

分配给新生代的最大容量为总堆内存的三分之一。

Server JVM Default Initial and Maximum Heap Sizes

The default initial and maximum heap sizes work similarly on the server JVM as it does on the client JVM, except that the default values can go higher. On 32-bit JVMs, the default maximum heap size can be up to 1 GB if there is 4 GB or more of physical memory. On 64-bit JVMs, the default maximum heap size can be up to 32 GB if there is 128 GB or more of physical memory. You can always set a higher or lower initial and maximum heap by specifying those values directly; see the next section.

默认的最小堆内存和最大堆内存容量在server模式的JVM和在client模式下类似,除了默认值更高。在32位的JVM上,如果机器有4GB以上的物理内存,默认的最大堆内存容量能够最大达到1GB。

在64位的JVM上,默认的最大堆大小能够达到32GB,如果有128GB以上的内存的话。

根据以上翻译,server模式下,如果电脑内存大于1GB,那么最大堆内存大小为机器内存的四分之1.

我本机验证了下,16GB内存大小,通过加-XX:+PrintFlagsFinal可以看到MaxHeapSize的值就是4G左右:

jdk的server模式修改无效(关于client和server模式)

以下的语句也能证明这一点:

jdk的server模式修改无效(关于client和server模式)

执行结果如下:max为3621M,和4G差得不算多。

jdk的server模式修改无效(关于client和server模式)

那么,再验证一下最小堆大小容量:

jdk的server模式修改无效(关于client和server模式)

268435456/(1024*1024) = 256M。

如果按照上面译文的算法,我本机16G内存的64分之一,为16G / 64 = 16 * 1024 / 64 M = 256M.

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,160
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,626
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,472
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,245
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,881
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,048