Talk about several jvm garbage collectors

Talk about several jvm garbage collectors

1. Serial collector (new generation)
  (1) Single-threaded collector
  (2) uses a copy algorithm for new generation garbage collection
  (3) STW (Stop The World) is required during garbage collection, STW means that the garbage collection thread does not match Concurrent execution of user threads
2.Serial Old collector (old generation)
  (1)Similar to Serial
  (2)Use mark sorting algorithm for immediate recovery in the old generation
3.ParNew collector (new generation)
  (1)Serial The multi-threaded version
  (2) is similar to Serial collection except for
4. Parallel Scavenge collector (new generation)
  (1) The basic function is similar to the ParNew collector
  (2) The difference is that the collector is to achieve a controllable throughput (Throughput = time to run user code/(time to run user code) + (time to garbage collection))
  (3) CPU time can be used efficiently
  (4) It provides parameters to accurately control throughput, respectively Control the maximum garbage collection pause time, and you can also directly set the throughput size.
5. Parallel Old collector (old generation)
  (1) The old version of the Parallel Scavenge collector, using the mark sorting algorithm.
6. CMS collector (old generation)
  ( 1) Using the mark-sweeping algorithm, garbage collection in the old age of users
  (2) The main concern is to shorten the pause time of user threads during garbage collection as much as possible
  (3) There are mainly the following steps:
    ①Initial marking: simply mark the nodes that GC ROOTS can directly associate to. STW is required at this stage. ②Concurrent
    marking: the process of GC Roots Tracing, which is executed concurrently with user threads at this stage. ③Remarking
    : for thread generation when marking concurrently To mark the new node of, STW is required at this stage, but this stage is multi-threaded parallel (multiple garbage collection threads are carried out at the same time)
    ④ Concurrent cleaning: the object is reclaimed using a clear algorithm, this phase is carried out at the same time as the same thread
  (4) Disadvantages:
    ①Floating garbage cannot be cleaned up. Since the last stage of concurrent cleanup is performed at the same time as the user thread, the user thread may generate new receivable objects.
    ②Garbage fragments may be generated, because the collector adopts It is the mark removal algorithm
7.
  G1 collector (1) G1 (Garbage-First)
  (2) G1 collector acts on the entire JVM heap
  (3) G1 collector divides the entire heap into independent regions of the same size (Region)
  ( 4) A priority list will be maintained in the background, and the region with the highest value will be reclaimed first according to the allowed collection time each time

Recommended reading:

  • In-depth analysis of HashMap and ConcurrentHashMap source code and underlying principles

  • Design pattern (2): detailed explanation of several factory patterns

  • Five mechanisms and advantages and disadvantages of process synchronization (translation)

  • Redis implementation of five data types, commonly used commands, application scenarios

  • The similarities, differences and application scenarios of redis and memcahed

  • Explain the three-way handshake and four-time wave of TCP and the interview questions (very comprehensive)

  • Arrays tool class detailed explanation (super detailed)

  • Algorithms must master several methods

  • QPS, TPS, number of concurrent users, throughput

  • Singleton pattern

  • Collections tools detailed explanation (super detailed)

END
Talk about several jvm garbage collectors
Scan the QR code| Follow our
WeChat public account: jiagoudiantang
CSDN: https://fking.blog.csdn.net

Guess you like

Origin blog.51cto.com/14977428/2545041