JVM Tuning Summary (ix)-a new generation of garbage collection algorithms

Source: Internet
Author: User
Tags garbage collection thread

The bottleneck of garbage collection

The traditional method of garbage collection has reduced the burden of recycling to a minimum and pushed the throughput of the application to a certain limit. But one of the problems he can't solve is the application pause that the full GC brings. In some applications where real time requirements are high, the request backlog and request failure caused by GC pauses are unacceptable. Such applications may require the requested return time of hundreds of or even dozens of milliseconds, if the generation of garbage collection to achieve this target, can only limit the maximum heap to a relatively small range of settings, but this has limited the application itself processing capacity, is also not acceptable.

The method of generation garbage collection does consider the real-time requirement and provides the concurrent collector, which supports the maximum pause time setting, but the memory partitioning model, which is limited by the generation of garbage collection, is not very satisfactory.

In order to achieve real-time requirements (in fact, the original Java language design is also on the embedded system), a new garbage collection method, it supports both short pause time, but also support large memory space allocation. Can be a good solution to the traditional way of generational problems.

Evolution of Incremental Collection

The method of incremental collection can theoretically solve the problems brought by traditional generational methods. Incremental collection divides the heap space into a series of memory blocks, when used, the first part (not all run out), the garbage collection of the previously used part of the surviving objects in the back of the unused space, so you can achieve the edge of the use of the collection of results, to avoid The traditional generational method has been used over and over again to suspend the recycling situation.

Of course, the traditional generational collection method also provides concurrent collection, but he has a very fatal place, is to make the whole heap as a block of memory, which will cause fragmentation (cannot be compressed), on the other hand, each of his collection is the entire heap of collection, can not choose, in the control of the pause time is still very weak. and incremental way, through the memory space of the block, just can solve the above problems.

Garbage firest (G1)

This part of the contents of the main reference here, this article is a G1 algorithm for the interpretation of the paper. I didn't add anything, either.

Goal

From the design goal to see G1 is entirely for large-scale applications prepared.

Support a lot of heaps

High throughput

--Support for multiple CPUs and garbage collection threads

--use parallel collection in case the main thread is paused

--Use concurrent collection in case the main thread is running

Real-time goal: configurable for garbage collection for up to M milliseconds in n milliseconds

Of course G1 to achieve real-time requirements, compared to the traditional generation of recycling algorithm, there will be some loss in performance.

Algorithm detailed

G1 is a long way to get to a perfect place. He learned the benefits of incremental collection, dividing the entire heap into one equal size area (region). Memory recovery and division are in region as the unit; At the same time, he also absorbed the characteristics of the CMS, the garbage collection process is divided into several stages, to disperse a garbage collection process; and, G1 also agree with the idea of generational garbage collection, that different objects have different life cycle, can take different collection methods, therefore, It also supports generational garbage collection. In order to achieve the predictability of the recovery time, after scanning the region, the size of the active object is sorted, and the region of the active object is collected first, in order to reclaim the space quickly (fewer active objects are to be replicated) because the active object is small, which can be considered as G1, So this approach is called the Garbage First (G1) garbage collection algorithm, which is: garbage priority recovery.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.