本文介绍了Tomcat 6和Tomcat 8中Java 1.8的内存分配行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相关问题:从Java 6 + Tomcat 6升级到Java 8 + Tomcat 8时垃圾收集器的使用情况

我有一组用Java 8编译的Web应用程序.如果我在Tomcat 8中运行它们,则会得到许多带有随机内存分配的次要GC集合.在Tomcat 6中,内存分配更加线性和稳定(在两种情况下均为空闲,没有流量).

I have a set of webapps, compiled with Java 8. If I run them in Tomcat 8, I get a lot of minor GC collections with a random memory allocation. In Tomcat 6 memory allocation is more linear and stable (idle in both cases, no traffic).

Eden Space Tomcat 8:

Eden Space Tomcat 8:

Eden Space Tomcat 6:

Eden Space Tomcat 6:

您知道为什么会这样吗?

Do you know why that happens?

这些是来自使用jdk 1.8和Tomcat 8的生产环境的数据.几乎总是由于GC周期,CPU确实很高.对此有何评论?

These are the data from production environment with jdk 1.8 and Tomcat 8.CPU is really high almost always due to GC cycles. Any comments about that?

这是一个堆转储解析(1.8GB转储):

This is a heapdump analisis (1.8GB dump):

推荐答案

这是eden空间,而不是保有期限的空间.因此,仅此而已是个好消息.

This is eden space, not the tenured space. So, that alone is good news.

但是,内存的这一步似乎是tomcat8在年轻的GC之后立即分配一些东西.可能是一些气球"技术吗? (分配一个大的弱引用缓冲区以快速缩小"以确保在内存不足的情况下有一定的空间).它也可能隐藏在NIO连接器中,例如'oomParachute'参数(默认为1 MB,但是否每个httpprocessor线程?如果您有200分钟的线程,那将与看到的200 MB相匹配).

But that step of memory appears to be tomcat8 allocating something right away after a young GC. Could it be some 'balloon' technique? (allocating a large weakly referenced buffer to 'deflate' rapidly to ensure some room in case of memory pressure). It may hide in NIO connectors too, as in the 'oomParachute' parameter (1 MB by default, but is it per httpprocessor thread? If you had 200 min threads, that would match the 200 MB seen).

我仅建议您可以深入查看更改日志以查找可能会像气球机制那样浪费实现的新事物或更改.

I will only suggest that you can drill into the changelog to find new thing or changes that you might think they implemented wastefully like such balloon mechanism.

也:您应该在jdk8中运行tomcat6来查看它是否真的是tomcat8的错误.可以将eden空间变大,以防万一G1GC非常激进以至于有义务仅使用200MB时就可以访问GC.

ALSO: you should run the tomcat6 in your jdk8 to see if it is really tomcat8 at fault. The eden space could be made larger, just in case the G1GC is so aggressive that it feels obligated to GC when a mere 200MB is used.

这篇关于Tomcat 6和Tomcat 8中Java 1.8的内存分配行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:26