JVM堆使用变化。这个图正常吗?

huangapple go评论71阅读模式
英文:

JVM heap usage variation. Is this graph normal?

问题

JVM堆使用变化。这个图正常吗?

这是一个预生产服务器在运行负载测试时的JVM内存使用情况(Xmx=10g)。我有几个问题。

  1. 垃圾收集器几乎每5分钟运行一次。在这5分钟内,堆内存从3GB增长到10GB。这种增长是否正常?如果不正常,如何分析我的应用程序中的问题?

  2. 在两次垃圾收集周期内,平均堆使用量逐渐下降,然后突然增加。这是什么原因?

  3. 在第二条评论中提到的逐渐下降过程中,没有出现平稳的下降,而是有一种震荡。这是什么原因?

英文:

JVM堆使用变化。这个图正常吗?

This is the JVM memory usage of a pre-production server while running a load test(Xmx=10g). I have few questions.

  1. Garbage collector has run almost each 5 minutes. During these 5 minutes heap has grown from 3GB to 10GB. Is this growth normal? If not, how is is possible to analyze the problem in my application?

  2. Within two garbage collector cycles, there is a gradual decrease and sudden spike of average heap usage. What is the reason for that?

  3. Inside the gradual decline mentioned in second comment, without having a smooth decline, there is a vibration. What is the reason for that?

答案1

得分: 8

这种堆利用模式有时被称为“锯齿形”,在您的情况下似乎保持稳定,看起来是健康的。请参阅《内存泄漏:谬误与误解》1一文,深入探讨常见的堆利用模式及其问题。

  1. 答案取决于应用程序代码,对于某些应用程序来说,这是正常的,对于其他应用程序来说则不是。唯一的方法是理解应用程序在做什么。

  2. 您很可能在运行并发GC,只要有可用内存,它就不会执行完整的GC循环。锯齿模式的“锯齿”可能是从幸存者空间移动到旧空间的活动对象。

  3. 与1相同。

与查看图片不同,您要了解一些基本参数,并判断它们对您的应用程序是否健康:

  1. 新空间GC的持续时间和频率是多少?

  2. 旧空间GC的持续时间和频率是多少?

  3. 在GC中花费了多少时间?

  4. 在GC中花费了多少CPU%?

  5. GC对应用程序延迟的影响是多少?

英文:

This heap utilisation pattern is sometimes called "a saw" and seems healthy as in your case it stays consistent. Take a look at Memory Leaks: Fallacies and Misconceptions article which dives deeper into common heap utilisation patterns and their problems.

  1. The answer depends on the application code, for some application it is normal for other it is not. The only way to figure it out is to understand what is the application doing.

  2. You are most likely running a concurrent GC which doesn't perform full GC cycle as long as there is available memory. The teeth of the saw pattern are probably live objects moving from the survivor space to the old space.

  3. Same as 1.

Instead of looking at the picture you want to understand some basic parameters and judge if they are healthy for your application:

  1. What is the duration and frequency of new space GC

  2. What is the duration and frequency of old space GC

  3. How much time is spent in GC

  4. How much CPU % is spent in GC

  5. Application latency impact by GC

huangapple
  • 本文由 发表于 2020年4月7日 19:45:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/61079322.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定