摘自:《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. http 常见的错误码

    翻译自:https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 常见错误码 一.信息 1XX (Information 1xx) ——这一类的状 ...

  2. 【转载】IntelliJ IDEA WEB项目的部署配置

    最近使用了一下IDEA,确实强大.在部署时出现了些问题.看了这篇文章,对ieda的一些部署配置有了些许了解,在此感谢原博.原文链接:http://blog.csdn.net/z69183787/art ...

  3. Spring初学之bean的生命周期

    实体Bean: Car.java: package spring.beans.cycle; public class Car { private String name; private int pr ...

  4. WebServers 异步

    在网上也找了一些,发现要么题目和内容不对应,明明是在Winform下异步调用,却写成在Asp.net异步调用WebService,有的调用方式在.NET3.5下不能通过,.NET3.5下取消了Begi ...

  5. 清北学堂(2019 5 1) part 4

    今天讲数论 1.进制问题(将n转换成k进制数): 1.方法:短除法 将n/k,保存,将商当做新的n,将余数保存,直到商为0,将余数(包括0),倒序输出,即得n的k进制数 2.关于高精四则运算(我本以为 ...

  6. 安装Xcode 7 beta后Xcode 6崩溃的问题

    最新解决方案:把OSX El Capitan升级到Beta 7  (15A263e),Xcode6可使用! 解决方案:http://stackoverflow.com/questions/318035 ...

  7. (转)轻量级C语言实现的minixml解析库入门教程

    svn上的minixml源码下载:svn co http://svn.msweet.org/mxml/tags/release-2.7/ 按照下载回来的源代码进行编译和安装.本教程只针对新手做一个引导 ...

  8. uva11054 - Wine trading in Gergovia(等价转换,贪心法)

    这个题看上去麻烦,实际上只要想清楚就很简单.关键是要有一种等价转换的思维方式.其实题意就是个一排数,最后通过相邻的互相移动加减使得所有数都变成零,移动过程中每次都耗费相应值,让耗费的值最小.虽然从实际 ...

  9. cmake安装MySQL数据库实例

    一.编译安装MySQL前的准备工作 首先检查是否有安装其他版本的编译器和数据库,先卸载干净. 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel p ...

  10. php mysql 查询

    抓取结果集对象中数据并且转换数组 $row = mysqli_fetch_assoc(结果集对象); 从结果集对象中抓取一行记录->转换关联数组 $row = mysqli_fetch_row( ...