如何计算GC工作所需的oldGen的大小?(How to calculate size for oldGen needed for work of GC?)

编程入门 行业动态 更新时间:2024-10-28 15:29:06
如何计算GC工作所需的oldGen的大小?(How to calculate size for oldGen needed for work of GC?)

我有java web(tomcat)应用程序,它消耗10G的堆内存(代表内存中的数据结构)。 但是当我将例如Xmx设置为20G时,它可以工作。

当我将堆内存设置为例如11G时,我的应用程序无法加载所有数据 - 它以连续的完整gc进入。 假设垃圾收集器还需要内存来使gc变得高效。 这是对的吗? 我应该为gc的高效工作添加多少内存? 谢谢。

I have java web (tomcat) application that consumes 10G of heap memory (represent data structure in memory). But it works when I will set e.g. Xmx to 20G.

When I set heap memory e.g. to 11G my application can not load all data - it enters in continuous full gc. Suppose that garbage collector also need memory to make full gc efficient. Does it correct? How much memory I should add for efficent work of gc? Thanks.

最满意答案

要找出最佳的OldGen尺寸

启用GC日志记录 -XX:+PrintTenuringDistribution -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log -XX:+HeapDumpOnOutOfMemoryError -Xloggc:gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -showversion

计算实时数据大小 = FullGC之后旧OldGen的占用率(有关详细信息,请参阅高级JVM调整 )。 顺便说一句。 试着平均。 通过观察几个FullGC循环后的OldGen占用率。

最佳OldGenSize = 实时数据大小的 2 3倍

To find out optimal OldGen size:

Enable GC logging -XX:+PrintTenuringDistribution -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log -XX:+HeapDumpOnOutOfMemoryError -Xloggc:gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -showversion

Calculate Live Data Size = occupancy of the old OldGen after a FullGC (see Advanced JVM Tuning for more details). Btw. try to get avg. by observing the OldGen occupancy after several FullGC cycles.

optimal OldGenSize == 2x to 3x of the Live Data Size.

更多推荐

本文发布于:2023-08-04 10:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1414135.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:所需   大小   工作   oldGen   GC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!