GC collector

①: Serial (serial) collector

  The most basic and oldest serial collector, single-threaded queue group game, before the default jdk1.5 collector.

  Advantages: simple and efficient, without the overhead of thread interaction.

  Disadvantages: single-threaded, it will only use a cpu / a collection thread to complete garbage collection.

  The corresponding algorithm: the young generation copy algorithm's old mark Collation Algorithm.

②: (multithreaded version Serial collector) ParNew collector

  Good multi-CPU system resource utilization, by default the same number of threads and CPU on the collection of single CPU Serial better results.

③: Paraller Scavenge collector

  Features: Parallel, the goal is to achieve a controlled throughput (user code running time / (spam run user code + phone time to time)), adaptive strategy.

  Advantages: the need for a user to interact with the program, a good response speed.

  Disadvantages: does not work with CMS collector.

④: CMS collector

  Advantages: concurrent low pause.

  Disadvantages: sensitive to CPU resources, procedures for concurrent design of CPU resources are sensitive, since taking up part of the thread (CPU resources) cause the program to slow down, reduce throughput, can not handle floating garbage, mark - sweep algorithm leads to memory fragmentation.

⑤: G1 collector

  Features: a distinctive way to organize memory heap, the memory heap is divided into a plurality of blocks of equal size, each memory block is a logically contiguous section of memory, the size of a N-th power of 2.

  G1 garbage collection offers three modes: Young GC, Mixed GC and Full GC, triggered under different conditions.

  Young GC occurred in the young generation GC algorithm, generic objects are allocated memory in Eden Region (except for giant objects), when it is run out of memory, it will trigger Young GC.

  Mixed GC when the object was promoted to the old era, in order to avoid heap memory is exhausted, the virtual machine will trigger mixed Mixed GC garbage collector, will recover the entire Young Region, also recovered part of the Old Region.

  Full GC if the object memory allocation too fast, Mixed GC too late to recover, leading to years old is full, it will trigger Full GC, is a serial old gc single thread of execution, will lead to an abnormally long pause time, we need to be constantly adjusted excellent, as far as possible to avoid the Full GC.

Guess you like

Origin www.cnblogs.com/rempop/p/11595166.html