我如何理解垃圾频繁收集的原因? [英] How do I understand the reason for frequent garbage collection?

查看:78
本文介绍了我如何理解垃圾频繁收集的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jstat -gc 27539
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
901632.0 468480.0  0.0    0.0   911360.0 911360.0 5464064.0  5463748.3  21632.0 20948.0 2944.0 2777.7    153   33.727  401   782.598  816.325

jstat -gccapacity 27539
 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC       MCMN     MCMX      MC     CCSMN    CCSMX     CCSC    YGC    FGC 
171008.0 2732032.0 2714624.0 901632.0 468480.0 911360.0   343040.0  5464064.0  5464064.0  5464064.0      0.0 1069056.0  21632.0      0.0 1048576.0   2944.0    153   404

我添加了EUOU来查找使用的总堆.看起来已经使用了6GB.我提到了

I added EU and OU to find the total heap used. That looks 6GB is used. I referred this

但是有400多个FGC发生了.现在已经达到700多个.一段时间后,它仅执行GC.现在是850 +.

But there are 400+ FGC happened. It has reached 700+ now. After sometime, it just performs GC. It is 850+ now.

我的工作:

这是多线程. 100个读者,100个作家线程.每个数据库都有其自己的连接.每个读取器线程读取100000条记录并存储在LinkedList中,然后发送到写入器线程. Writer将数据写入同一数据库中的另一个集合. LinkedList不会重复使用,这意味着每个1L都会创建一个新的LinkedList.

It is multi threading. 100 reader, 100 writer threads. Each one has it's own connection to the database. Each reader thread reads 100000 records and stores in a LinkedList and sends to writer thread. Writer writes the data to another collection in the same database. LinkedList is not reused means each 1L creates a new LinkedList.

它是基于akka的多线程.所以我不处理线程失败,线程生成(即线程管理)的问题.

It is akka based multi-threading. So I don't handle thread failure, thread spawning i.e thread management.

但是我的疑问是,当我拥有32GB RAM时,为什么会发生如此巨大的FGC?有什么指针需要进一步看吗?

But my doubt is that why such huge FGC happening when I have 32gb ram? any pointers to look further?

有时会遇到GC Overhead LIMIt超出错误.

It ran into GC Overhead LIMIt exceeded error sometimes.

我没有为工作设置任何明确的最小,最大内存.

I didn't set any explicit min, max memory for the job.

根据我的分析,它已经修复了一些EUOU.它已满,因此继续执行GC.有可能吗,我正确吗?

As per my analysis, it has fixed some EU and OU. It is full, hence it is keep on performing GC. Is it possible and am I correct?

Edit2

感谢@ emotionlessbanans,@ Cascader.我有以下内容.

Thanks @emotionlessbanans, @Cascader. I have the below.

    uintx ErgoHeapSizeLimit                         = 0                                   {product}
    uintx HeapSizePerGCThread                       = 87241520                            {product}
    uintx InitialHeapSize                          := 526385152                           {product}
    uintx LargePageHeapSizeThreshold                = 134217728                           {product}
    uintx MaxHeapSize                              := 8392802304                          {product}
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)

当我有8GB内存时,只有6GB停止的任何特定原因吗?还是我错过了什么?

Any specific reason to stop at only 6GB when I have 8gb ? Or am I missing something?

推荐答案

使用-Xmx开关未指定最大堆大小时,JVM将选择一个默认值.此值是JVM供应商特定的,通常取决于体系结构(32/64位)和总可用内存.

When no max heap size is specified using -Xmx switch, the JVM chooses a default value. This value is JVM vendor specific and it usually depends on architecture (32/64bit) and total available memory.

似乎您的应用程序使用了所有分配的内存(由JVM确定的内存),从某个角度看,它在GC上花费了太多时间,直到您收到超出了GC开销上限".错误.

It seems like your application uses all allocated memory (the one determined by your JVM) and from some point on it spends too much time on GC until you get "GC Overhead Limit Exceeded" error.

您应明确设置最大堆大小(即-Xmx 10g),以确保您利用了所有可用内存.

You should explicitly set a maximum heap size (i.e. -Xmx 10g) in order to be sure you utilize all of your available memory.

这篇关于我如何理解垃圾频繁收集的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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