当前位置:网站首页>What is gossip (E-Net gossip)

What is gossip (E-Net gossip)

2022-07-28 14:17:00 Full stack programmer webmaster

Hello everyone , I meet you again , I'm your friend, Quan Jun .

This article is based on JDK 1.8, The collector used is ParNew + CMS

Preface

The origin of this article is like this , In the early morning of last Friday, I was forced to participate in the double 11 pressure test duty , A business party suddenly called to say that there was a memory leak problem in the client we provided, which caused the online application to continue full gc, I was about to fall asleep and immediately became refreshed , Check it out , Finally, it is located that the client has a bug It will cause some data to be held all the time into the elderly generation gc Do not drop , As a result, the frequency of the old age gc, Specifically bug Not yet , A very strange phenomenon attracted my attention , That is, from the perspective of the monitoring system , This app averages one minute full gc As many as ten times , According to my previous understanding full gc Shi Shihui stop the world Of ,stop the world The frequency is so high , Then the service of the application itself has knelt down , But look at the business indicator monitoring of this application , Unexpectedly, everything is normal , This is a little beyond my understanding , Later, in order to solve this problem , For what is full gc, And how to see full gc I have consulted a lot of information , I finally understand full gc The concept , In the process of checking the information, I found that there are too many wrong information in the Chinese community , And most of them are copied around , Very misleading , So I plan to write an article , Correct some wrong ideas .

Text

Pre knowledge points

In the real beginning of exploration Full GC Before , We need to introduce some concepts first

GC

GC Its full name is garbage collection, The Chinese meaning is garbage collection , stay jvm Reclaim useless memory space

Young space

The Chinese name is young generation or new generation , by JVM Part of the pile , By generation GC From the concept division , Save objects with a short life cycle

Tenured space

The Chinese name is old age or old generation , by JVM Part of the pile , By generation GC From the concept division , Save objects with a long life cycle

Minor GC

minor gc It refers to the young generation or the new generation (Young space) Medium gc, Others call it young gc perhaps ygc, In the following, we use minor gc Express

Major GC

major gc It refers to the elderly generation (Tenured space) Medium gc, Some people call it old gc,o gc,cms gc etc. , In the following, we use major gc Express

stop the world

This means that the user thread is running to a safe point (safe point) Or a safe area (safe region) after , Just hang up , Enter the pause state , External performance looks like the world has stopped working , No matter what gc Algorithm , Whether it's minor gc still major gc Metropolis stop the world, The only difference is stop the world The length of time .

What is? Full GC

Let's start with the conclusion ,Full GC There is no official definition of this concept , And the meaning is particularly confusing , The meanings expressed in different places are different , Different scenarios need to be discussed separately .

Public cognition

In the usual sense, people say Full GC For a special GC Description of the act , This time, GC It will reclaim the memory of the whole heap , Including the elderly generation , The new generation ,metaspace etc. , This is the most common kind of cognition , Many people also know this degree , Therefore, when you encounter some special scenes, you will find that the actual situation will conflict with your own cognition

from GC On the log

stay gc.log It will be found in part gc There are also in the log header Full GC Such words , The meaning here is in this GC In the whole process of , All are Stop The world The state of , That is to say, this time GC All user threads are suspended throughout the process , Then spray Chinese here jvm Divinity book 《 In depth understanding of JVM》 了 , In the Second Edition 89 There is a passage on page :

GC At the beginning of the log “[GC” and “[Full GC” Explain the type of pause in this garbage collection , Not to distinguish the new generation GC Or the old generation GC Of . If there is “Full”, Explain this GC It happened Stop-The-World Of , For example, the next generation collector ParNew There will also be “[Full GC”( This is generally due to the distribution Problems such as guarantee failure . That's why STW). If it's a call to System.gc() Collection triggered by method , So here it will show “[Full GC (System)”.

The description of this paragraph is wrong , Because I said before , Whatever gc Algorithm , Whether in the new generation or the old age , Its gc Will happen stop the world, The correct description here is this time GC The whole process is Stop-The-World Of

from JDK On your own tools

Use jstat -gc Commands can be viewed to make java Thread gc frequency , After many attempts and comparisons , I found using jstat Found out FGC Times and times , In fact, it refers to the collector occurrence in the old age Stop the world The number and duration of , Corresponding to this article , Namely CMS Collector's Stop the world Times and times

Other meanings ( Pit father version )

I didn't mention that I saw this application happen more than ten times a minute on the monitoring market ”Full GC” Well , After I understand the first two Full GC After checking the meaning of gc.log file , Then it was found that the application was actually once Full GC None of them , Then I consulted the students who provided monitoring data , As a result, he said it was through JMX Acquired , The code is :

ManagementFactory.getGarbageCollectorMXBeans()

Then as we all know , Use MXBean All we get is the execution times of the collector , and Full GC Half a cent doesn't matter , Then I asked , Students who find that they are working on the monitoring system directly CMS The collection times of the collector are taken as Full GC Count the number of times ,what the fuck????, Only for FUll GC Many people have never understood the concept of

Conclusion

At the end of this article , use google After a casual search, I found an article on the home page for all kinds of gc An article with a thorough introduction to the concept , Compared with using Du Niang's search home page, which is full of all kinds of wrong articles copied around , The contrast is simply too strong , From this we come to the conclusion that , Technical information can be checked on the Internet , Save time and effort , Finally, I find the This article It seems that plumbr Written by the co-founder of , I have to say it's very awesome

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/128616.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207281211232778.html