摘自:《Java Performance》第三章

Initial Heap Space Size Configuration

This section describes how to use live data size calculations to determine an initial Java heap size. Figure 7-3 shows the fields that identify an application’s live data size. It is wise to compute an average of the Java heap
occupancy and garbage collection duration of several full garbage collections for your live data size calculation. The more data you collect, the better the estimate for a Java heap size starting point.

Using the live data size information, an informed decision can be made on an initial Java heap size to use along with an estimate of the worst case latency due to full garbage collections.

As a general rule, the initial and maximum Java heap size command line options, -Xms and -Xmx, should be set to a value between three and four times larger than the live data size of the old generation space. In the full garbage
collection data shown in Figure 7-3, the old generation space occupancy after the full garbage collection is 295111K, or about 295 megabytes. Hence, the live data size is about 295 megabytes. Therefore, the suggested initial and maximum Java heap size to specify
for this application should be a value between 885 and 1180 megabytes, that is,

-Xms1180m -Xmx1180m for four times the live data size. In Figure 7-3, the Java heap size in use is 1048570K, about 1048 megabytes. This Java heap size is at the upper end of the recommendation.

Also as a general rule, the initial and maximum permanent generation size, -XX:PermSize and -XX:MaxPermSize, should be 1.2x to 1.5x larger than the live data size of the permanent generation space. In the example full garbage
collection shown in Figure 7-3, the permanent generation space occupancy after the full garbage collection is 32390K, or about 32 megabytes. Hence, the suggested initial and maximum permanent generation space size to specify for this application should be
between 38  megabytes and 48 megabytes, that is, -XX:PermSize=48m -XX:MaxPermSize=48m, for 1.5 times the permanent generation live data size. In Figure 7-3, the permanent  generation space size in use is 65536K, about 65 megabytes. Although
this is above the recommended size of 38 to 48 megabytes, 17 additional megabytes in the  context of a 1 gigabyte Java heap space is not worth worrying about.

As an additional general rule, the young generation space should be 1 to 1.5 times the old generation space live data size. In the example full garbage collection shown in Figure 7-3, the live data size is about 295 megabytes.
As a result, the suggested young generation size should be between 295 and 442 megabytes. In Figure 7-3, the young generation space size is 358400K, about 358 megabytes. 358 megabytes is within the recommended size.

If the initial and maximum Java heap size is 3x to 4x the live data size and the young generation space is 1x to 1.5x the live data size, the size of the old generation space should be between 2x to 3x the live data size.

The combined Java command line applying these general sizing rules based on the garbage collection data in Figure 7-3 is:

$ java -Xms1180m -Xmx1180m -Xmn295m -XX:PermSize=48m -XX:MaxPermSize=48m

Guidelines to follow when calculating Java heap sizing are summarized in Table 7-3.

Java堆初始大小的建议值的更多相关文章

  1. 一步步优化JVM四:决定Java堆的大小以及内存占用

    到目前为止,还没有做明确的优化工作.只是做了初始化选择工作,比如说:JVM部署模型.JVM运行环境.收集哪些垃圾回收器的信息以及需要遵守垃圾回收原则.这一步将介绍如何评估应用需要的内存大小以及Java ...

  2. tomcat服务器配置java堆内存大小

    我用的是绿色免安装的tomcat,找到tomcat下的bin文件夹下的catalina.bat文件: 编辑该文件,编辑参数,没有的话手动加上: set JAVA_OPTS=-server -Xms51 ...

  3. Java 堆内存(Heap)[转]

    将jvm内存很不错的文章,转自 堆(Heap)又被称为:优先队列(Priority Queue),是计算机科学中一类特殊的数据结构的统称.堆通常是一个可以被看做一棵树的数组对象.在队列中,调度程序反复 ...

  4. java堆内存详解

    http://www.importnew.com/14630.htmljava堆的特点<深入理解java虚拟机>是什么描述java堆的 Java堆(Java Heap)是java虚拟机所管 ...

  5. Java堆内存溢出模拟

    先了解一下Java堆: 关于Java内存区域的分配,可以查看Java运行时数据区域一篇文章. Java堆是虚拟机内存管理中最大的一块区域,该区域是线程共享的,某Java进程中所有的线程都可以访问该区域 ...

  6. 从 Java 代码到 Java 堆

    本文将为您提供 Java 代码内存使用情况的深入见解,包括将 int 值置入一个 Integer 对象的内存开销.对象委托的成本和不同集合类型的内存效率.您将了解到如何确定应用程序中的哪些位置效率低下 ...

  7. 优化Java堆大小5温馨提示

    总结:Java没有足够的堆大小可能会导致性能非常大的影响,这无疑将给予必要的程序,并不能带来麻烦.本文总结了影响Java居前五位的能力不足,并整齐地叠优化? 笔者Pierre有一个10高级系统架构师有 ...

  8. 优化Java堆大小的5个技巧

    本文作者Pierre是一名有10多年经验的高级系统架构师,他的主要专业领域是Java EE.中间件和JVM技术.根据他多年的工作实践经验,他发现许多性能问题都是由Java堆容量不足和调优引起的.下面他 ...

  9. Java中初始变量默认值

    Java语言中有8种基本数据类型,基本情况汇总如下: 序号 数据类型 大小/位 封装类 默认值 可表示数据范围 1 byte(位) 8 Byte 0 -128~127 2 short(短整数) 16 ...

随机推荐

  1. vim 乱码问题的方法参考

    linux 中设置当前用户的系统默认编码为 UTF-8 格式解决 vim 乱码问题的方法参考  任侠  2013-05-02 11:58  电脑基础  抢沙发  13,732 views  在使用 l ...

  2. Linux嵌入式 -- 内核 - proc文件系统

    1. 什么是proc文件系统? 实例:通过 /proc/meminfo,查询当前内存使用情况. 结论:proc文件系统是一种在用户态检查内核状态的机制. 2.Proc文件分类 特点  每个文件都规定了 ...

  3. js外观模式

    外观模式为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 外观模式类图: 然而对于外观模式而言,是没有一个一般化的类图描述,下面演示一个外观模式的 ...

  4. php如何查看扩展是否开启

    php如何查看扩展是否开启 一.总结 一句话总结:php -m 1.查看php已安装扩展命令 ? php -m 2.phpinfo();这是最常用的方法,但那么多扩展一时还真不太好找.? 3.exte ...

  5. JAVA常见函数

    输入函数 : Scanner cin=new Scanner(System.in); int a=cin.nextInt();    //输入一个int数据 double dl=cin.nextDou ...

  6. 清新大气的ListView下拉上拉刷新--第三方开源--PullDownListView

    下载地址:https://github.com/guojunyi/PullDownListView 使用: xml: <com.pulldownlistview.PullDownListView ...

  7. @angular/cli项目构建--modal

    环境准备: cnpm install ngx-bootstrap-modal --save-dev impoerts: [BootstrapModalModule.forRoot({container ...

  8. HihoCoder1415后缀数组三·重复旋律3

    重复旋律3 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为长度为 N 的数构成的数列.小Hi在练习过很多 ...

  9. Find The Multiple(DFS)

    Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal repr ...

  10. git统计当前分支提交次数

    切换到您要统计的分支,然后Git Bash here,执行如下代码即可 : git log --author="您的用户名" --since='开始日期' --oneline | ...