Memory management during JVM GC and reasons for frequent GC

1. If the objects are small and have a short life cycle, frequent GC is required to release these objects from memory.

2. If the object is relatively large and has a long life cycle, frequent GC is not needed because they mainly exist in Old Generation.

 

        During garbage collection, the Eden area and the From area are scanned. If the object is still alive after the GC, the object will be copied to the To area. If the space of To is full, it may be placed in Old Generation. Therefore, the minimum number of GC times for an object to enter Old Generation is 0.

The young generation garbage collection adopts the method of copying.

       Frequent GC may be artificial, such as code calling GC. Another possibility is that the framework calls the GC method. When the heap is relatively small, frequent GC will definitely occur. Also constructing and releasing objects is particularly frequent.

       When performing GC, Heap generally has 50-70% of the space left, which is a relatively healthy space.

       The importance of the cache can allocate as much space as possible to the Heap. The cache should count the hit rate. The higher the better, otherwise it will occupy both memory and IO and GC.

 

Guess you like

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