简体   繁体   English

JVM 足够的内存但频率满 gc

[英]JVM enough memory but frequency full gc

JVM Options: -Xms512M -Xmx512M -XX:PermSize=70M -XX:MaxPermSize=70M JVM 选项:-Xms512M -Xmx512M -XX:PermSize=70M -XX:MaxPermSize=70M

jstat -gc 8260 5000 jstat -gc 8260 5000

S0C:512.0 S1C:512.0 S0U:0.0 S1U:0.0 EC:174080.0 EU:0.0 OC:349696.0 OU:45191.1 PC:71680.0 PU:34882.2 YGC:2216225 YGCT:6754.909 FGC:2216144 FGCT:160651.466 GCT:167406.375 S0C:512.0 S1C:512.0 S0U:0.0 S1U:0.0 EC:174080.0 EU:0.0 OC:349696.0 OU:45191.1 PC:71680.0 PU:34882.2 YGC:221626161G461G461G74G4G1G7461G461G74G74G74G74G45G74G45G45G45G41G46165

S0C:512.0 S1C:512.0 S0U:0.0 S1U:64.0 EC:174080.0 EU:0.0 OC:349696.0 OU:45187.3 PC:71680.0 PU:34882.2 YGC:2216253 YGCT:6755.047 FGC:2216172 FGCT:160653.488 GCT:167408.535 S0C:512.0 S1C:512.0 S0U:0.0 S1U:64.0 EC:174080.0 EU:0.0 OC:349696.0 OU:45187.3 PC:71680.0 PU:34882.2 YGC:2216260000:2216260735G25G2060CT300000000:0.0 OC:349696.0 OU:45187.3

S0C:512.0 S1C:512.0 S0U:0.0 S1U:128.0 EC:174080.0 EU:0.0 OC:349696.0 OU:45189.6 PC:71680.0 PU:34882.2 YGC:2216281 YGCT:6755.180 FGC:2216200 FGCT:160655.542 GCT:167410.721 S0C:512.0 S1C:512.0 S0U:0.0 S1U:128.0 EC:174080.0 EU:0.0 OC:349696.0 OU:45189.6 PC:71680.0 PU:34882.2 YGC:225G1620C:225G1620G15G16207000000000

S0C:512.0 S1C:512.0 S0U:0.0 S1U:0.0 EC:174080.0 EU:1775.6 OC:349696.0 OU:45187.3 PC:71680.0 PU:34882.2 YGC:2216308 YGCT:6755.309 FGC:2216227 FGCT:160657.627 GCT:167412.936 S0C:512.0 S1C:512.0 S0U:0.0 S1U:0.0 EC:174080.0欧盟:1775.6 OC:349696.0 OU:45187.3 PC:71680.0 PU:34882.2 YGC:2216308 YGCT:6755.309 FGC:2216227 FGCT:160657.627 GCT:167412.936

S0C:512.0 S1C:512.0 S0U:128.0 S1U:0.0 EC:174080.0 EU:0.0 OC:349696.0 OU:45187.3 PC:71680.0 PU:34882.2 YGC:2216336 YGCT:6755.444 FGC:2216255 FGCT:160659.701 GCT:167415.146 S0C:512.0 S1C:512.0 S0U:128.0 S1U:0.0 EC:174080.0 EU:0.0 OC:349696.0 OU:45187.3 PC:71680.0 PU:34882.2 YGC:225G16640F:225G16740G175G1640G175G167465

Why JVM frequency full gc happened?为什么会发生 JVM 频率 full gc?

It is hard to tell, but one possible explanation is that you are repeatedly allocating and discarding very large arrays.很难说,但一种可能的解释是您反复分配和丢弃非常大的数组。

If I am interpreting the stats correctly, the Eden space is 174MB, the Survivor spaces are 0.5MB, and the Old space is 349MB.如果我正确解释统计数据,Eden 空间是 174MB,Survivor 空间是 0.5MB,而 Old 空间是 349MB。 If you allocate an array that is too large to put into the Eden space, it will be allocated straight into Old space.如果分配的数组太大而无法放入 Eden 空间,它将直接分配到 Old 空间。 If the Old space fills, that may trigger a full GC.如果旧空间已满,则可能会触发完整的 GC。

How big is "big"? “大”有多大? Well it is complicated, because there is also the issue of the TLAB and its size, the -XX:PretenureSizeThreshold option and differences between different kinds of GC.嗯,这很复杂,因为还有-XX:PretenureSizeThreshold及其大小、 -XX:PretenureSizeThreshold选项以及不同类型 GC 之间的差异的问题。 Read "Java Garbage Collection Distilled" by Martin Thompson to get you started on the issues.阅读 Martin Thompson 的“Java Garbage Collection Distilled”以开始解决这些问题。


If this is not the problem then you need to do a deeper investigation of what is happening in your heap.如果这不是问题,那么您需要对堆中发生的事情进行更深入的调查。 Figure out what the mix of objects is, their rates and patterns of allocation / disposition, etc to try and figure out why so many are ending up in the Old space.弄清楚对象的混合是什么,它们的比率和分配/处置模式等,以尝试弄清楚为什么这么多对象最终会进入旧空间。

After 3-5 days works fine, this happens 3-5 天后工作正常,会发生这种情况

That tends to suggest that something is building up in your application's in-memory data structures over those three to five days of operation.这往往表明在这三到五天的操作中,应用程序的内存数据结构中正在建立某些东西。 Investigate that scenario.调查那个场景。

Your survivor spaces are very small.你的幸存者空间非常小。 Just 512KB.只有 512KB。 If the survivor space fills up on a clean up of the Eden space it triggers a Full GC.如果幸存者空间在清理 Eden 空间时填满,则会触发 Full GC。

As your Eden spaces is ~300 x larger, I would be surprised if they were not filling up.由于您的伊甸园空间大 ~300 倍,如果它们没有填满,我会感到惊讶。

I would check that you are not creating a lot of very short lived objects which is why the JVM thinks hardly anything survives.我会检查您是否没有创建很多非常短暂的对象,这就是为什么 JVM 认为几乎没有任何东西可以存活的原因。

For example, see if you can parse/process your UDP packet without creating objects.例如,看看您是否可以在不创建对象的情况下解析/处理您的 UDP 数据包。

When heap and stack memory looks good, try to find memory leak about "Direct Memory".当堆和堆栈内存看起来不错时,尝试查找有关“直接内存”的内存泄漏。 In my case, part of Netty5-ByteBuf didn't released.就我而言,Netty5-ByteBuf 的一部分没有发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM