Overview of Java garbage collection GC

InfoQ 2020-11-10 17:23:44
overview java garbage collection gc


{"type":"doc","content":[{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" Automatic memory management "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     This part of the content can be said to be the top priority , There was C/C++ Developers should know the importance and difficulty of memory management . although Java I realized the memory management , There's no need for developers to worry about , But its memory management still has shortcomings , Often there are problems with memory leaks and memory overflows . When we go through these problems , I don't know about it JVM Memory management knowledge , That's blindness , No direction , Only by mastering this knowledge can we have a basis when solving problems ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     This part of memory mainly involves two blocks , One is the memory model , The memory model is the foundation , It affects the memory management , It also involves the problem of multi thread competition , Concurrency is also a big problem , I won't go into details here . The second is the basics of garbage collection and all kinds of GC Algorithm , Understand and master GC The algorithm is helpful for problem analysis and performance tuning , This is also quite important , But the feeling doesn't have to go deep into GC Algorithm code details , Understand the main idea of the algorithm , There's a need to go deeper ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    GC The use of tools and log analysis requires more hands-on practice ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":" Memory model "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/e1/e13645a3c3aa4ca89c7226acbff7c88e.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     Above, Java Virtual machine runtime database , There are five parts to master : Method area 、 Pile up 、 Virtual machine stack 、 Native Method Stack 、 Program counter "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Program counter : Bytecode line number indicator ; Thread private "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Java Virtual machine stack :Java The thread memory model of execution , Storing basic data types and object references ; Thread private "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Native Method Stack : by Java Method service , And Java The virtual machine stack is similar to ; Thread private "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Pile up : Store object instance ; Thread sharing "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Method area : Type information loaded 、 Constant 、 Static variables 、 Compile the compiled code cache and other data immediately ; Thread sharing "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" - Runtime constant pool : Store the version of the class 、 Field 、 Method 、 Interface and other description information , And the constant pool table ( Store various literal quantities and symbol references generated during compilation )"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     There are also non runtime data areas : Direct memory . This part will also be used frequently "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     Which of the above will have OOM The phenomenon :Java Virtual machine stack ( Variables are constantly stored )、 Native Method Stack ( Continuous recursion )、 Pile up ( Objects are constantly stored )、 Method area ( Class information is constantly stored )、 Direct memory "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    OOM For example, you can refer to : In depth understanding of Java virtual machine :JVM Advanced features and best practices 》 Of 2.4 actual combat :OutOfMemoryError abnormal "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":" Basic knowledge of garbage collection "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     There are some pre knowledge about garbage collection : Criteria for recycling ( Reachability analysis algorithm )、 Generational collection theory 、 Three basic algorithms for garbage collection "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":" Reachability analysis algorithm "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     Reachability analysis algorithm : Mainly through enumeration GC Roots Start as the root node , What can be traversed is to live objects "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/b3/b34f1907fbd6c0336db17612f901f811.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     stay Java In the technical system , Fixed as GC Roots The objects include the following :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" In the virtual machine stack ( Local variables in stack frames ) Object referenced in , For example, the parameters used in the method stack that each thread is called 、 local variable 、 Temporary variables, etc ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Objects referenced by class static properties in method area , for example Java Class reference type static variable ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Objects referenced by constants in the method area , For example, string constant pool (String Table) Quote from ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" In the local method stack JNI( That is what is usually said Native Method ) Referenced object ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Java References inside the virtual machine , For example, the basic data type corresponds to Class object , Some resident exception objects ( such as NullPointExcepiton、OutOfMemoryError) etc. , And the system class loader ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" All are locked in sync (synchronized keyword ) The object of holding ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" reflect Java What's going on inside the virtual machine JMXBean、JVMTI Callback registered in 、 Local code cache, etc ."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":" Generational collection theory "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     In the important generational Hypothesis , stay ZGC Before ,GC Algorithms are designed around this assumption "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Weak generational Hypothesis (Weak Generational Hypothesis): The vast majority of objects are born and perished ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Strong generational Hypothesis (Strong Generational Hypothesis): The more times you go through the garbage collection process, the more difficult it is for an object to die ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Cross generational citation Hypothesis (Intergenerational Reference Hypothesis): Cross generation references account for only a very small number of references compared to the same generation references ."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":" Garbage collection algorithm "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     This is quite important , So far GC At least one of the algorithms is used in the algorithm design "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"###### Mark - Clear algorithm "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/03/035239dc10b90009fb17a903f896823f.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     Like its name , There are two stages: marking and clearing : First mark the object that needs to be cleared , Clear the mark when it is finished "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" advantage : The foundation is simple "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" shortcoming :"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" - The first is that the efficiency of execution is not stable , If Java The heap contains a large number of objects , And most of it needs to be recycled , At this time, a lot of marking and clearing must be done , As a result, the execution efficiency of both marking and cleaning processes decreases with the increase of the number of objects "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" - The second is the fragmentation of memory space , Mark 、 After clearing, a large number of discontinuous memory fragments will be generated , Too much space fragmentation may lead to the failure to find enough continuous memory when large objects need to be allocated during the running process of the program, and another garbage collection action will have to be triggered in advance "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"###### Mark - Copy algorithm "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/b3/b33799fbea6a307ff4fb5ba11c113cf7.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     It divides the available memory into two equal sized blocks according to the capacity , Use only one piece at a time . When this block of memory runs out , Copy the living object to another piece , Then clean up the used memory space at a time . If most objects in memory are alive , This algorithm will generate a lot of memory replication overhead , But most objects are recyclable , What the algorithm needs to replicate is a small number of surviving objects , And every time, it is for the entire half of the memory recycling , When allocating memory, you don't have to consider the complexity of space fragmentation , Just move the top pointer , Just distribute them in order ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    G1 And the younger generation of the previous algorithms use this idea to recycle garbage . Because there are few survivors , Replication takes less time "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" advantage : Implement a simple , Efficient operation , No space debris "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" shortcoming : Reduce available memory by half , There's too much space to waste "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"###### Mark - Sorting algorithm "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ac/acb33d9b3a385c507897e1d2da847d17.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     Mark - When the survival rate of objects is high, replication algorithm needs more operations , Efficiency will be reduced . More to the point , If you don't want to waste 50% Space , There needs to be extra space for distribution guarantees , In response to all objects in memory being used 100% The extremes of survival , So we can't choose this algorithm directly in the old age ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     The marking process is still related to “ Mark - eliminate ” Algorithm is the same , But the next step is not to clean up the recyclable objects directly , Instead, let all living objects move to one end of the memory space , Then clean up the memory outside the boundary ,“ Mark - Arrangement ” The schematic diagram of the algorithm is shown in the figure above ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     There's also room for flexible adjustments , It can be sorted out in time , It can also be sorted out when fragmentation is to a certain extent "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" advantage : No space debris , High space utilization "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" shortcoming : Moving live objects and updating all references to them would be a very heavy operation , And this kind of object moving operation must be suspended in the whole process of user application "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Serial The collector "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/9a/9ac3a1e41520f27be1334bd506a17be3.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     As shown in the figure above ,Serial The collection is a single threaded , In its garbage collection , Business code must be stopped , Let it concentrate on recycling , There is a figurative metaphor in the book :“ When your mother is cleaning your room , I'm sure it will make you stay on the chair or outside the room , If she cleans at the same time , You're throwing scraps of paper , The room can still be cleaned ?”"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     Its Cenozoic uses markers - Copy algorithm , The old days use markers - Sorting algorithm "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"ParNew The collector "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/5e/5e237d4dab901c8a790890497702f404.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     As shown in the figure above ,ParNew Is based on Serial The parallel version of , Nothing else has changed , The idea is to use multithreading to speed up garbage collection "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     Its Cenozoic uses markers - Copy algorithm , The old days use markers - Sorting algorithm "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Parallel Scavenge The collector "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    Parallel Scavenge The collector's feature is that its focus is different from other collectors ,CMS The focus of the collector is to minimize the pause time of the user thread during garbage collection , and Parallel Scavenge The goal of the collector is to achieve a manageable throughput (Throughput). Throughput is the ratio of the time the processor spends running user code to the total elapsed time of the processor "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     The collector is designed to achieve set throughput , It can also be adjusted intelligently "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Serial Old The collector "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/48/4870e5f6273d2d4f51f1e3cc0a19f315.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    Serial Old yes Serial Old age version of collector , It is also a single-threaded collector , Use the tag - Sorting algorithm . The main meaning of this collector is also for the client mode HotSpot Virtual machine usage . If you are in server mode , It may also have two uses : One is in JDK 5 As well as previous versions of the Parallel Scavenge Collector used with , The other is as CMS Backup plan in case of collector failure , Occurs during concurrent collection Concurrent Mode Failure When using ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Parallel Old The collector "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/14/141ed479ce4ddcd629ac6aef600edc6c.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     until Parallel Old After the collector appears ,“ Throughput priority ” The collector finally has a more real combination of collocations , In the case of paying attention to throughput or processor resource scarcity , You can give priority to Parallel Scavenge Add Parallel Old Collector combination ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"CMS The collector "}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/33/337adf4542032bae376ddec6db9d8023.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    CMS It's a breakthrough node , The breakthrough point is to subdivide the garbage collection nodes , To shorten STW Time , Some of the recycling process can run with business code ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    CMS(Concurrent Mark Sweep) A collector is one that aims to obtain the shortest recovery pause time . At present, a large part of Java Applications focused on Internet sites or browser based B/S On the server side of the system , This kind of application usually pays more attention to the response speed of the service , I hope the system pause time is as short as possible , To bring users a good interactive experience .CMS Collector is very suitable for this kind of application ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    CMS It's based on markers - Clear algorithm , As shown in the figure above , There are four steps :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Initial marker : need STW; Mark GC Roots Objects that can be directly related to , fast "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Concurrent Tags : Unwanted STW; Mark GC Roots The object directly associated with starts traversing the tag ( Concurrent )"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Re label : need STW; Correction phase 2 The part of a concurrent tag that changes due to business operations "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4) Concurrent elimination : Unwanted STW; Clean up and delete dead objects , There are memory fragments "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    CMS It has the following advantages and disadvantages :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" advantage : Concurrent collection 、 Low pause , It is suitable for the fast response needs of today's Internet servers "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" shortcoming :"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" - Sensitive to resources , The core 4 Or better , The impact is great , Take resources "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" - Because of floating garbage , A part of space should be reserved for concurrent collection , Not too low or too high "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" - There's space debris "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"G1 GC"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/c6/c607ffcb7e08e85f761f202285675343.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    G1 GC It's a milestone , The breakthrough is the redesign of memory layout (Region), Controllable maximum pause time . It can be said that these designs and improvements , from CMS At the beginning, they were all aimed at the high response server side ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    G1 It can be roughly divided into the following four stages :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Initial marker (Initial Marking): Just to mark GC Roots Objects that can be directly related to , And modify TAMS Pointer value , Let the next phase of user threads run concurrently , Can be used correctly in Region Assign new objects to . This stage needs to pause the thread , But it takes a short time , And it's on loan Minor GC When the synchronization is completed , therefore G1 The collector doesn't actually have an extra pause at this stage ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Concurrent Tags (Concurrent Marking): from GC Root Start the reachability analysis of the objects in the heap , Recursively scans the entire heap for object graphs , Find out what to recycle , This stage takes a long time , But it can be executed concurrently with the user program . When the object image scanning is finished , And we have to deal with it again SATB Recorded objects with reference changes in concurrency ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Final marker (Final Marking): Make another brief pause for the user thread , It is used to deal with the last few left after the end of the concurrent phase SATB Record ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4) Screening and recovery (Live Data Counting and Evacuation): Is responsible for updating Region Statistical data , To each Region Sorted by recovery value and cost , Make a recycling plan based on the user's expected pause time , You can choose as many as you like Region Make up a recycling set , And then the part that decided to recycle Region Of live objects copied to empty Region in , And clean up the whole old Region The whole space of . The operation here involves moving the living object , It is necessary to pause the user thread , Done in parallel by multiple collector threads ."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     About G1 Whether the algorithm has STW pause , Here's an example of a gang of thieves :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1) Let's mark the map together : First, mark the richer families on the map , Ready to step on , Mark... On the map , The map is still , Corresponding needs STW"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2) Division of labor for the inspection : You need to go to specific places to check , People come and go , This time is not static , Unwanted STW"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3) Meet and confirm on the map : We meet to confirm which people are richer and better to steal , Mark it on the map , Corresponding needs STW"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4) Split up and start : It must be dark and windy at this time , Or no one's home , Or sleep soundly , Corresponding needs STW"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    G1 Advantages and disadvantages :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" advantage : A controlled 、 Low latency 、 Basically no debris ,6G-8G A more appropriate "}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" shortcoming : Inter generational recycling produces card tables , Takes up more memory , The processing is more complicated ,6G The following may be CMS good "}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Shenandoah"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/e1/e17730b47fd51970596347497fa07ea8.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    shennadoah It feels like G1 On the basis of the most further improvement , The general steps are as follows , There is no detailed analysis here :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Initial marker (Initial Marking): And G1 equally , First mark with GC Roots Directly associated objects , This stage is still “Stop The World” Of , But the pause time has nothing to do with the heap size , Only with GC Roots The quantity is related to ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Concurrent Tags (Concurrent Marking): And G1 equally , Traversal object graph , Mark all accessible objects , This phase is concurrent with the user thread , The length of time depends on the number of surviving objects in the heap and the structural complexity of the object graph ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Final marker (Final Marking): And G1 equally , Deal with the rest SATB scanning , And at this stage, the highest value of recycling Region, Will these Region Make up a collection (Collection Set). There will also be a short pause in the final marking phase ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Concurrent cleanup (Concurrent Cleanup): This stage is used to clean up those objects that have not been found in the whole area Region( This kind of Region go by the name of Immediate Garbage Region)."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Concurrent recovery (Concurrent Evacuation): The concurrent recycle phase is Shenandoah Prior to HotSpot The core differences of other collectors in . At this stage ,Shenandoah You need to make a copy of the living object back in the collection to the unused one Region In . Copying objects is a fairly simple thing to do if the user thread is frozen , But if both have to be done simultaneously , It's complicated . The difficulty is moving objects at the same time , The user thread may still have read and write access to the moved object , Moving objects is a one-time behavior , But after the move, all references to the object in the whole memory are still the address of the old object , It's hard to change it all in a moment . For these difficulties encountered in the concurrent recovery phase ,Shenandoah Will pass through the reading barrier and be called “Brooks Pointers” Forward pointer to solve ( That's all Shenandoah After the whole process, the author will introduce it again ). The duration of the concurrent recycle phase depends on the size of the recycle set ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Initial reference update (Initial Update Reference): After copying objects in the concurrent recycle phase , You also need to fix all references to old objects in the heap to new addresses after copying , This operation is called reference update . The initialization phase of the reference update doesn't actually do anything specific , This phase is only set up to create a thread collection point , Ensure that all collector threads in the concurrent recycle phase have completed the object movement task assigned to them . The initial reference update time is very short , There will be a very short pause ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Concurrent reference updates (Concurrent Update Reference): Actually start the reference update operation , This phase is concurrent with the user thread , The length of time depends on the number of references involved in memory . Concurrent reference updates are different from concurrent tags , It no longer needs to search along the object graph , Just follow the memory physical address order , Search for reference types linearly , Change the old value to the new value ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Final quote update (Final Update Reference): After resolving the reference update in the heap , And fix the existing GC Roots Citation in . This stage is Shenandoah The last pause of , The pause time is only with GC Roots The quantity is related to ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Concurrent cleanup (Concurrent Cleanup): After concurrent recycling and reference updates , The whole collection of all Region There are no more living objects , these Region All become Immediate Garbage Regions 了 , Finally, call the concurrent cleanup process again to recycle these Region Of memory space , For later allocation of new objects ."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"ZGC"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/a2/a2265ba9e01dd01e893f54af52a7eb52.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"    ZGC Collector is based on Region Memory layout ,( temporary ) Without generations , Read barrier used 、 Technologies such as coloring pointer and memory multiple mapping are used to implement concurrent tags - Sorting algorithm's , A garbage collector with low latency as the primary goal ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     First of all, from the ZGC About the memory layout of . And Shenandoah and G1 equally ,ZGC Also based on Region The heap memory layout of , But unlike them ,ZGC Of Region( In some official sources it is called Page perhaps ZPage, This chapter continues to be called Region) It's dynamic —— Dynamically create and destroy , And the dynamic area capacity . stay x64 Under the hardware platform ,ZGC Of Region It can be as shown in the figure 3-19 Large as shown 、 in 、 Small three kinds of capacity :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" small Region(Small Region): The capacity is fixed to 2MB, Used to place less than 256KB The little object of ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" medium Region(Medium Region): The capacity is fixed to 32MB, Used to place more than or equal to 256KB But less than 4MB The object of ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" large Region(Large Region): The capacity is not fixed , Can change dynamically , But it has to be 2MB Integer multiple , For placement 4MB Or above . Each large Region Only one large object will be stored in , It also indicates that although the name is “ large Region”, But it is likely to have a real capacity of less than medium Region, The minimum capacity can be as low as 4MB. large Region stay ZGC Will not be reallocated in the implementation of ( Redistribution is ZGC A kind of processing action of , The collector phase for copying objects , I'll talk about it later ) Of , Because copying a large object is very expensive ."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     Next is ZGC Core issues of —— The implementation of concurrent collation algorithm . Dye pointer technology "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The coloring pointer can be used to make once a certain Region After the living objects of are removed , This Region It can be released and reused immediately , You don't have to wait for all the points in the whole heap to Region We can only clean up the references after they have been corrected . Compared with this point Shenandoah It's a big advantage , In theory, as long as there is still a spare time Region,ZGC Can complete the collection , and Shenandoah You need to wait until the end of the reference update phase to release the Region, This means the extreme case where almost all objects in the heap survive , need 1∶1 Copy object to new Region Words , You have to have half the time Region To complete the collection . As for why dyeing pointers can lead to such results , The author will explain it later “ self-healing ” When the feature is explained ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Coloring pointers can significantly reduce the number of memory barriers used during garbage collection , Set up a memory barrier , In particular, the purpose of the write barrier is usually to record changes in object references , If you maintain this information directly in the pointer , Obviously, you can save some special record operations . actually , up to now ZGC There's no writing barrier used , Only the reading barrier is used ( Part of it is the dyeing of the pointer , Part of it is ZGC Generational collection is not supported yet , Naturally, there is no cross generational reference problem ). The memory barrier's loss of runtime performance has been explained in the previous section , Can eliminate a part of the memory barrier , Obviously, it is beneficial to the efficiency of the program , therefore ZGC The impact on throughput is also relatively low ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Colored pointers can be used as an extensible storage structure to record more and more object tags 、 Relocation process related data , In order to further improve the performance in the future . Now? Linux Under the 64 Bit pointer and front 18 Bits are not used , They can't be used to address , But it can be used to record information by other means . If you develop this 18 position , You can spare what you have used 4 Flag bits , take ZGC The maximum heap memory that can be supported is from 4TB Expand to 64TB, You can also store more flags with the rest of the location , For example, it can store some trace information so that the garbage collector can move low-frequency objects to areas of memory that are rarely accessed when moving objects ."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     The general steps are as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Concurrent Tags (Concurrent Mark): And G1、Shenandoah equally , Concurrent markup is the stage of traversing object graph for reachability analysis , Before and after, it's like G1、Shenandoah The initial tag of 、 Final marker ( Even though ZGC These are not the names in ) A brief pause of , And what these pauses do is similar in goal . And G1、Shenandoah The difference is ,ZGC The tag for is on the pointer rather than on the object , The marking phase updates the Marked 0、Marked 1 Sign a ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" And prepare for reallocation (Concurrent Prepare for Relocate): At this stage, we need to find out what to clean up in the collection process according to the specific query conditions Region, Will these Region Make up a reallocation set (Relocation Set). Reallocation sets and G1 Collection of collectors (Collection Set) There's a difference ,ZGC Divide Region It's not to be like G1 That way, revenue first incremental recovery . contrary ,ZGC Every time it's recycled, it's scanning everything Region, Save... In exchange for larger scan costs G1 The maintenance cost of the middle memory set . therefore ,ZGC The reallocation set only determines that the surviving objects in it will be copied to other objects Region in , Inside Region Will be released , It is not to say that the recycling behavior is only aimed at the Region Conduct , Because the tagging process is for the entire heap . Besides , stay JDK 12 Of ZGC Class offloads and weak reference processing that are supported in , It's also done in this stage ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Concurrent reallocation (Concurrent Relocate): Redistribution is ZGC The core stage in the implementation process , This process copies the live objects in the reallocation set to the new Region On , And redistribute each of the sets Region Maintain a forwarding table (Forward Table), Record the transition from the old object to the new object . Thanks to the support of colored pointers ,ZGC The collector can know whether an object is in the reallocation set by reference only , If the user thread concurrently accesses the object in the reallocation set , This visit will be intercepted by the preset memory barrier , Then immediately according to Region The forward table record on forwards access to the newly replicated object , At the same time, update the value of the reference , Make it point directly at the new object ,ZGC Call this behavior pointer “ self-healing ”(Self-Healing) Ability . The advantage of this is that only the first time you access an old object will you fall into forwarding , It's only slow once , contrast Shenandoah Of Brooks Forwarding pointer , That's the fixed overhead that every object accesses , In short, it's slow every time , therefore ZGC The runtime load on the user program is greater than Shenandoah Come a little lower . Another direct benefit is the presence of coloring pointers , Once redistributed, focus on a Region After all the live objects of are copied , This Region You can immediately release the allocation for new objects ( But the forwarding table has to be kept and can't be released ), It doesn't matter if there are still many unmodified pointers to this object in the heap , Once these old pointers are used , They are self-healing ."}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Concurrent remapping (Concurrent Remap): All remapping does is fix all references in the whole heap to old objects in the reassignment set , From a goal point of view, this is related to Shenandoah The concurrent reference update phase is the same , however ZGC Concurrent remapping is not a must “ urgent ” To complete the task , Because I said before , Even if it's an old quote , It can also heal itself , At most, it's just one more forward and fix operation on the first use . The main purpose of remapping cleans up these old references is not to be slow ( There are also spin offs that can be released after the clean-up ), So it's not very “ urgent ”. therefore ,ZGC It's very clever to put the work to be done in the concurrent remapping phase , Merge to the next garbage collection cycle in the concurrent marking phase to complete , Anyway, they all need to traverse all objects , In this way, merging saves the overhead of traversing the object graph once . Once all the pointers have been fixed , The forwarding table that records the relationship between the old and the new objects can be released ."}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"GC The evolution of the algorithm "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     stay GC The development of algorithms , Personal feeling is always around a point : Reduce the single STW Time ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     For example, using multithreading to accelerate recycling , To reduce serialization GC The whole time of recycling STW Time ; Refine the recycling process , In stages , One more time STW It's divided into small parts , It's distributed in various recycling stages , It also reduces the number of single times STW Time ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     and GC The evolution direction of the algorithm is to meet the fast response of the server ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"     The algorithm evolution diagram is as follows :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/76/7651d9c208780b0a4f5e624b541da2f5.png","alt":" Insert picture description here ","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" Reference link "}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://blog.oio.de/2020/01/13/high-performance-at-low-cost-choose-the-best-jvm-and-the-best-garbage-collector-for-your-needs/","title":""},"content":[{"type":"text","text":"High performance at low cost – choose the best JVM and the best Garbage Collector for your needs"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://www.vogella.com/tutorials/JavaLibrary-OkHttp/article.html","title":""},"content":[{"type":"text","text":"Using the OkHttp library for HTTP requests - Tutorial - Tutorial"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://search.maven.org/artifact/com.squareup.okhttp3/okhttp/4.9.0/jar","title":""},"content":[{"type":"text","text":"com.squareup.okhttp3:okhttp:4.9.0"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://stackoverflow.com/questions/57330923/okhttp-nosuchmethoderror-copyinto-in-tlsutil","title":""},"content":[{"type":"text","text":"OkHttp: NoSuchMethodError copyInto in TlsUtil"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://github.com/aliostad/SuperBenchmarker","title":""},"content":[{"type":"text","text":"aliostad/SuperBenchmarker"}]}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云