简体   繁体   English

Java Metaspace Full GC

[英]Java Metaspace Full GC

I am having some issues with G1GC.我在使用 G1GC 时遇到了一些问题。

2400.241: [GC concurrent-root-region-scan-start]
2400.241: [Full GC (Metadata GC Threshold) 2400.252: [GC concurrent-root-region-scan-end, 0.0101404 secs]
2400.252: [GC concurrent-mark-start]
 1151M->603M(4356M), 2.6980537 secs]
   [Eden: 0.0B(2558.0M)->0.0B(2613.0M) Survivors: 55.0M->0.0B Heap: 1151.7M(4356.0M)->603.6M(4356.0M)], [Metaspace: 259187K->92248K(1034240K)]
 [Times: user=3.92 sys=0.00, real=2.70 secs] 

This is taking a long time and every 20-30 minutes a full gc is triggered by metaspace.这需要很长时间,每 20-30 分钟,元空间就会触发一次完整的 gc。 I configured it this way:我是这样配置的:

  "-XX:MaxMetaspaceSize=768M",
  "-XX:MetaspaceSize=256M"

But everytime it hits 256M~ it triggers a full gc.但是每次达到256M~都会触发一次完整的gc。 When it reach this first high-water-mark should not it make it bigger next time until the max size?当它达到第一个高水位线时,它下次不应该让它变大直到最大尺寸吗? Also, a full gc on metaspace triggers a full gc on old gen?此外,元空间上的完整 gc 会触发旧 gen 上的完整 gc? I read it somewhere but I am not sure about it.我在某处读过它,但我不确定。 This is getting the p99 response time to be higher than I expected.这使 p99 响应时间比我预期的要高。

According to Triggering of gc on Metaspace memory in java 8 , the full GC is needed in order to reduce metaspace usage.根据Triggering of gc on Metaspace memory in java 8 ,需要完整的 GC 以减少元空间使用。

My understanding is that metaspace is not garbage collected per se .我的理解是元空间本身不是垃圾收集的。 Instead, you have objects in the ordinary heap that hold special references to metaspace objects.取而代之的是,普通堆中的对象持有对元空间对象的特殊引用。 When the objects are collected by the GC, the corresponding metaspace objects are freed.当对象被 GC 收集时,相应的元空间对象被释放。 (Conceptually it is like finalization where the finalizer is free -ing the metaspace objects.) (从概念上讲,它就像终结器是free元空间对象的终结器。)

When it reach this first high-water-mark should not it make it bigger next time until the max size?当它达到第一个高水位线时,它下次不应该让它变大直到最大尺寸吗?

Apparently not.显然不是。 The normal strategy for HotSpot collectors is like this: HotSpot 收集器的正常策略是这样的:

  1. allocate objects until you hit the current heap limit分配对象,直到达到当前的堆限制
  2. run the collector运行收集器
  3. look at how much space was reclaimed, and increase (or decrease) the heap size if warranted.查看回收了多少空间,并在必要时增加(或减少)堆大小。

It seems that the same strategy is used here.这里似乎使用了相同的策略。 And the full GC is causing enough metaspace to be reclaimed that it decides that it doesn't need to expand metaspace.并且完整的 GC 导致足够的元空间被回收,它决定不需要扩展元空间。

A band-aid for this would be to try setting -XX:MetaspaceSize and -XX:MaxMetaspaceSize to the same value, but that will just make the full GCs less frequent.对此的创可贴是尝试将-XX:MetaspaceSize-XX:MaxMetaspaceSize设置为相同的值,但这只会降低完整 GC 的频率。

A real solution would be to figure out what is consuming the metaspace, and fix it.一个真正的解决方案是弄清楚是什么在消耗元空间,并修复它。

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

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