gpt4 book ai didi

spring-boot - spring boot 2 actuator jvm.gc.memory.allocated 公制

转载 作者:行者123 更新时间:2023-12-05 02:04:56 27 4
gpt4 key购买 nike

我正在使用 spring boot 2.2.5 并通过 spring boot actuator 和 Grafana 监控我的应用程序指标。

我的应用程序使用 Docker(OpenJdk11) 打包并配置了 4GB 内存

我有大约 1-2 秒的长时间 gc 暂停,它与高 jvm.gc.memory.allocated 相关。

jvm.gc.memory.allocated 指标有时会达到 30GB

谁能解释一下 jvm.gc.memory.allocated 指标?这是什么意思?

最佳答案

如果您问我,这是一个相当奇怪的指标(从某种意义上说,掌握它并非易事)。让我们慢慢来。

首先由micrometer生成here如果您阅读了它的描述:

Incremented for an increase in the size of the young generation memory pool after one GC to before the next

这对您来说可能也没什么意义。我必须查看计算它的代码,才能了解它的作用。

如果您了解有关 GC 工作原理的一些基本知识,并且 look at this code ,其实事情很简单。

垃圾收集器(如 G1)将堆分成区域(young)。新对象的分配发生在年轻区域(除非humongous,但我不会深入),特别是在伊甸园空间。一旦 GC 被触发,Eden 就会被清除并且分配可以再次发生。这是相当简化的并且不是完全正确的(在 major/mixed 集合的情况下情况略有不同)。

现在这个理论已经到位,你可以看看什么是isYoungGenPool,来自:

if (youngGenPoolName != null) {
final long youngBefore = before.get(youngGenPoolName).getUsed();
final long youngAfter = after.get(youngGenPoolName).getUsed();
final long delta = youngBefore - youngGenSizeAfter.get();
youngGenSizeAfter.set(youngAfter);
if (delta > 0L) {
allocatedBytes.increment(delta);
}
}

具体定义为here :

... endsWith("Eden Space")

因此,此代码拍摄快照 - Eden 中的 GC 循环之前之后已用空间 Space,计算一个 delta 并将所有这些 delta 添加到一个值中。这就是 jvm.gc.memory.allocated 的含义。


这种方法衡量您的应用程序在其生命周期内分配了多少空间,但仅限于 young 空间。恕我直言,你应该仔细看看它,因为:

  • 它不跟踪大量分配(对此有不同的指标)

  • 它只适用于分代垃圾收集器(Shenandoah 不是这样的收集器)

关于spring-boot - spring boot 2 actuator jvm.gc.memory.allocated 公制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63880261/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com