为什么我的垃圾收集日志显示 3.8GB 作为最大可用堆大小而我分配了 4GB 作为最大堆大小? [英] Why does my garbage collection log show 3.8GB as the max available heap size while I have allocated 4GB as the max heap size?

查看:24
本文介绍了为什么我的垃圾收集日志显示 3.8GB 作为最大可用堆大小而我分配了 4GB 作为最大堆大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 64 位 RHEL 6 机器上安装了 64 位热点 JDK 1.7.0 版.我为我的 tomcat 应用程序使用了以下 JVM 选项.

I have a 64-bit hotspot JDK version 1.7.0 installed on a 64-bit RHEL 6 machine. I use the following JVM options for my tomcat application.

CATALINA_OPTS="${CATALINA_OPTS} -Dfile.encoding=UTF8 -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -Duser.timezone=EST5EDT"

# General Heap sizing
CATALINA_OPTS="${CATALINA_OPTS} -Xms4096m -Xmx4096m -XX:NewSize=2048m -XX:MaxNewSize=2048m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+UseCompressedOops -XX:+DisableExplicitGC"

# Enable the CMS GC policy
CATALINA_OPTS="${CATALINA_OPTS} -XX:+UseConcMarkSweepGC -XX:CMSWaitDuration=15000 -XX:+CMSParallelRemarkEnabled -XX:+CMSCompactWhenClearAllSoftRefs -XX:+CMSConcurrentMTEnabled -XX:+CMSScavengeBeforeRemark -XX:+CMSClassUnloadingEnabled"

# Verbose Garbage Collection Logging
CURRENT_DATE=`date +%Y%m%d%H%M%S`
CATALINA_OPTS="${CATALINA_OPTS} -verbose:gc -XX:+PrintGCDetails -Xloggc:${CATALINA_BASE}/logs/gc-${CURRENT_DATE}.log -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution"

当我进行垃圾回收分析时,GC 日志显示分配给 JVM 的最大可用堆只有 3.8GB,而不是 4GB.这是为什么?

When I have a Garbage Collection analysis, the GC logs show a maximum available heap of only 3.8GB instead of 4GB allocated to the JVM. Why is that?

推荐答案

New Generation (2048M) 由 80% 的 Eden (1638.4M) 和两个 Survivor Spaces(每个 10% 或 204.8M)组成:

New Generation (2048M) consists of 80% Eden (1638.4M) and two Survivor Spaces (10% or 204.8M each):

Heap
 par new generation   total 1887488K, used 134226K [0x00000006fae00000, 0x000000077ae00000, 0x000000077ae00000)
  eden space 1677824K,   8% used [0x00000006fae00000, 0x00000007031148e0, 0x0000000761480000)
  from space 209664K,   0% used [0x0000000761480000, 0x0000000761480000, 0x000000076e140000)
  to   space 209664K,   0% used [0x000000076e140000, 0x000000076e140000, 0x000000077ae00000)
 concurrent mark-sweep generation total 2097152K, used 242K [0x000000077ae00000, 0x00000007fae00000, 0x00000007fae00000)

在任何时候,幸存者空间之一是空的(参见 世代).
所以,有用的堆大小是 1638.4 + 204.8 + 2048 = 3891.2 MB

At any time one of survivor spaces is empty (see Generations).
So, the useful heap size is 1638.4 + 204.8 + 2048 = 3891.2 MB

这篇关于为什么我的垃圾收集日志显示 3.8GB 作为最大可用堆大小而我分配了 4GB 作为最大堆大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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