Java堆初始大小的建议值
摘自:《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堆初始大小的建议值的更多相关文章
- 一步步优化JVM四:决定Java堆的大小以及内存占用
到目前为止,还没有做明确的优化工作.只是做了初始化选择工作,比如说:JVM部署模型.JVM运行环境.收集哪些垃圾回收器的信息以及需要遵守垃圾回收原则.这一步将介绍如何评估应用需要的内存大小以及Java ...
- tomcat服务器配置java堆内存大小
我用的是绿色免安装的tomcat,找到tomcat下的bin文件夹下的catalina.bat文件: 编辑该文件,编辑参数,没有的话手动加上: set JAVA_OPTS=-server -Xms51 ...
- Java 堆内存(Heap)[转]
将jvm内存很不错的文章,转自 堆(Heap)又被称为:优先队列(Priority Queue),是计算机科学中一类特殊的数据结构的统称.堆通常是一个可以被看做一棵树的数组对象.在队列中,调度程序反复 ...
- java堆内存详解
http://www.importnew.com/14630.htmljava堆的特点<深入理解java虚拟机>是什么描述java堆的 Java堆(Java Heap)是java虚拟机所管 ...
- Java堆内存溢出模拟
先了解一下Java堆: 关于Java内存区域的分配,可以查看Java运行时数据区域一篇文章. Java堆是虚拟机内存管理中最大的一块区域,该区域是线程共享的,某Java进程中所有的线程都可以访问该区域 ...
- 从 Java 代码到 Java 堆
本文将为您提供 Java 代码内存使用情况的深入见解,包括将 int 值置入一个 Integer 对象的内存开销.对象委托的成本和不同集合类型的内存效率.您将了解到如何确定应用程序中的哪些位置效率低下 ...
- 优化Java堆大小5温馨提示
总结:Java没有足够的堆大小可能会导致性能非常大的影响,这无疑将给予必要的程序,并不能带来麻烦.本文总结了影响Java居前五位的能力不足,并整齐地叠优化? 笔者Pierre有一个10高级系统架构师有 ...
- 优化Java堆大小的5个技巧
本文作者Pierre是一名有10多年经验的高级系统架构师,他的主要专业领域是Java EE.中间件和JVM技术.根据他多年的工作实践经验,他发现许多性能问题都是由Java堆容量不足和调优引起的.下面他 ...
- Java中初始变量默认值
Java语言中有8种基本数据类型,基本情况汇总如下: 序号 数据类型 大小/位 封装类 默认值 可表示数据范围 1 byte(位) 8 Byte 0 -128~127 2 short(短整数) 16 ...
随机推荐
- lua 写逻辑打印log时,打印到一半后停止不再打印,程序停止
问题描述:ubuntu下用lua开发游戏电子邮件模块,自己测试时向用户推送100封,而用户最多只能有50封.这是调用sysdelete删除一些邮件.当打印log时,打印到一半后程序中途停止.将打印lo ...
- eclipse安装hibernate插件(在线Marketplace中安装)
网上很多都是给个网址,然后在eclipse的help中new install soft中安装.每次安装还要去查找最新的地址去安装.为什么不用eclipse的marketplace直接搜索安装呢? 打开 ...
- Functions should do one thing一个函数应该只做一件事
if you take nothing else away from this guide other than this, you'll be ahead of many developers. 如 ...
- RocketMQ原理讲解系列文章
[RocketMQ原理解析][http://blog.csdn.net/quhongwei_zhanqiu/article/category/2548637] [消息的可靠性.顺序和重复][https ...
- 重写ddt的mk_test_name方法
一. 测试用例名字的问题 使用ddt做测试,得到的测试报告中,测试用例的名字默认以_01, _02, _03...递增的形式结尾,这时我希望用例名能够以_api_name结尾,比如注册模块,希望看到的 ...
- python中的SMTP发送邮件
一. 介绍 python3中自带了smtplib模块和email模块 smtplib模块:负责与邮件服务器的交互 email模块:负责组织邮件内容 二. smtplib模块 smtplib模块:主要是 ...
- 解决:TypeError: 'list' object is not callable
如果list变量和list函数重名,会有什么后果呢?我们可以参考如下代码: list = ['泡芙', '汤圆', '鱼儿', '骆驼'] tup_1 = (1, 2, 3, 4, 5) tupToL ...
- 51nod 1257 01分数规划/二分
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1257 1257 背包问题 V3 基准时间限制:3 秒 空间限制:1310 ...
- PCA算法详解——本质上就是投影后使得数据尽可能分散(方差最大),PCA可以被定义为数据在低维线性空间上的正交投影,这个线性空间被称为主⼦空间(principal subspace),使得投影数据的⽅差被最⼤化(Hotelling, 1933),即最大方差理论。
PCA PCA(Principal Component Analysis,主成分分析)是一种常用的数据分析方法.PCA通过线性变换将原始数据变换为一组各维度线性无关的表示,可用于提取数据的主要特征分量 ...
- syq小姐姐的分享的历年考试经验
一>读题 10~20min浏览题目,把握题目方向和做题大致顺序 不要轻敌,最好先看完题目,大概掌握整套题的难度顺序再动手 仔细读题步骤: (1)文件名(也是检查的重点,绝对重要,注意区分l和1和 ...