我有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.
更多推荐
发布评论