jvm heap memory generation

In the jvm heap memory, it can be roughly divided into the new generation, the old generation, and the permanent generation (which can be regarded as the method area in the past). Since the current jvm has gone to the permanent generation, there are essentially only the first two types.

1. Cenozoic: The Cenozoic is further divided into eden area and two survivor areas. The default size ratio is 8:1. Most of the newly generated objects are directly allocated in eden. If a gc is executed in the new generation, the unreclaimed objects in eden     will enter the survivor area, and the age of the object +1 , After multiple GCs, if the age is greater than a threshold, the object will enter the old age. Because many objects have a short life cycle, this part of the

gc can often reclaim most of the memory (about 80%). The gc in this area becomes minor gc or young gc.

2. Old generation: Generally, large objects or objects in the new generation that have not been recycled after multiple GCs enter this area. This part of gc is called full gc. The execution time of full gc is long. At the same time, because all executing threads are suspended during gc, if

                 The memory in the old generation area is too large. Once gc is executed, the longer the interruption time, the worse the user experience will be.

Therefore, the premise of allocating large memory to JVM is to ensure that the frequency of full gc execution is low. Generally, full GC is performed once every ten hours or a day, so that full GC can be triggered by executing scheduled tasks in the middle of the night and even the application server can be automatically restarted to keep the available memory space at a stable level. The key to controlling the frequency of Full GC is to ensure the stability of the old generation. Otherwise, the bigger the memory allocation, the worse the actual usage.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325942105&siteId=291194637