Java class loader & Java garbage collection method

1. The Java class loader is

divided into
A boot class loader Boostrap Classloader
loads all classes in jre/lib/rt.jar according to the loading order, which is implemented by C++, not a ClassLoader subclass

B Extension class loader Extension Classloader
loads jre/ jar package in the directory specified by lib/*.jar or

-Djava.ext.dirs C system loader System(App) Classloader
loads the jar package specified in the classpath and class

D in the directory Custom loader Customer Classloader
application according to its own needs A custom ClassLoader, such as tomcat, will implement the ClassLoader according to the j2ee specification . 2. Java

garbage collection methods

Two basic Java recycling algorithms: copy algorithm & tag cleaning algorithm
Java implements generational recycling (new generation and old generation: new generation The replication algorithm is basically used, and the marking and sorting algorithm is used in the old age.)

A Replication algorithm There
are two areas A and B. The initial object is in A, and the objects that continue to survive are transferred to B. This is the most commonly used algorithm for the new generation.
B Marking and cleaning algorithm
A region, marking the objects to be recycled, then recycling, fragmentation occurs, defragmenting, sorting out larger memory and storing larger objects

1.Serial New/Serial Old
    The Serial/Serial Old collector is the most basic and oldest collector. It is a single-threaded collector and must suspend all user threads while it is garbage collecting. The Serial New collector is a collector for the new generation, using the Copying algorithm, and the Serial Old collector is a collector for the old generation, using the Mark-Compact algorithm. The advantage is that it is simple and efficient to implement, but the disadvantage is that it can bring pauses to the user.
2.Parallel New
    The Parallel New collector is a multi-threaded version of the Serial collector (refer to Serial New), which uses multiple threads for garbage collection.
3. Parallel Scavenge
    Parallel Scavenge collector is a new generation of multi-threaded collector (parallel collector), it does not need to suspend other user threads during recycling, it adopts Copying algorithm, this collector and the first two collectors Different, it is mainly to achieve a manageable throughput.
4.Parallel Old
    Parallel Old is the old version of the Parallel Scavenge collector (parallel collector), using multithreading and Mark-Compact algorithm.
5.CMS
    CMS (Current Mark Sweep) collector is a collector whose goal is to obtain the shortest recovery pause time. It is a concurrent collector and adopts the Mark-Sweep algorithm.
6.G1 The
    G1 collector is the most cutting-edge achievement in the development of collector technology. It is a collector for server-side applications, which can make full use of multi-CPU and multi-core environments. So it is a parallel and concurrent collector, and it can model predictable pause times.

Reference URL: https://www.nowcoder.com/questionTerminal/795b066b67c84478aec4dc400b3d0153

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327094496&siteId=291194637