JVM knowledge - other sort of knowledge

Other sort of knowledge

Detailed generational recovery

As mentioned earlier, java heap memory management is generational, generational management is to facilitate garbage collection, do so based on two facts. First, most of the objects will soon no longer used, second, there are still some not useless immediately, but it will not last long.

Virtual machines are divided into younger generations, old time, and permanent generations.

1> the young generation : mainly used to store the newly created object, the young generation is divided into two zones and eden Survivor areas. Most objects generated in the Eden area. When the Eden area is full, objects that survive will be alternately held in two Survivor areas, up to a certain number of objects promoted to the old era.

2> years old : used to store promotion comes from the young generation, longer survival time of the object.

3> perpetual generations : Save the main class information, etc., on behalf of the permanent division of the object here is the way, not exclusively permGen 1.7 or later metaspace 1.8.

According to the characteristics of the young generation and the old age, jvm provides a different garbage collection algorithm. Garbage collection algorithm can be classified by reference counting method, transfer method, and tag clearance method.

Wherein a reference notation is used to determine whether the object is referenced by the number of times the object, the disadvantage is the problem can not be solved circular references.

Copy algorithm requires two memory space from and to the same size, only when the object in the allocation from the block, the recovery of live objects copied to the block and the block from empty, then the exchange of two division, i.e., from the to block as a block from the block as a block to. The disadvantage is that lower memory usage.

Clear labeling algorithm is divided into objects and clear labeling of the object is not in use in two stages, marking clear disadvantage of the algorithm is to produce memory fragmentation.

The young generation collection algorithm Serial, ParNew, Parallel Scavenge jvm replication algorithms are provided, and CMS, G1, zgc belong to mark sweep algorithm.

Welcome to the concern of my personal micro-channel public number, which is not only technology sharing, as well as a variety of industries interesting, let your life become colorful

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_45154607/article/details/93748575