JAVA Old generation collector 10th Section

Source: Internet
Author: User

JAVA Old generation collector 10th Section

In the previous chapter we talked about the new generation of collectors, so this chapter is about the old generation of some collectors. The survival of the old age is generally large objects and life is very tenacious object , so the new generation of replication algorithm is obviously unable to adapt to the characteristics of the region, so the old age used is the "mark-clear-tidy" algorithm (previous chapters have been discussed in detail).

Serilalold Collector: The Collector is the old version of the serial collector, also a single-threaded collector , the advantages and disadvantages of the serial collector, there is not much to say.

Parallel old collector: In the code example of our previous article, the default older generation collector is also the older version of the Parallel scavenge collector. The focus is also the same as the parallel scavenge collector, which focuses on the throughput of the system and is suitable for CPU resource-sensitive situations .

CMS (Concurrent Mark Sweep) Collector: A collector that targets the shortest pause time . When the application attaches particular importance to the response speed of the service, I hope the system can have the shortest pause time, the collector is very suitable. The collection process is more complex than the previous collectors, and the collection process is divided into four steps:

Initial Tag

Concurrency token

Re-tagging

Concurrent cleanup

Let's start by describing what each process means, and how he achieves the goal of the shortest pause time. The initial tag needs to be STW, but only the object that the GC roots can directly relate to (not the Dead object Oh ~), because of the existence of Oopmap, the step is very fast. , where the blue shading is the object that can be directly associated.
Then it goes to the second step, the concurrency tag. This step is not need STW, do not need! He worked with our main program threads, starting with the object that was tagged in the previous step and making accessibility analysis a "network". Because SWT is not required, this step does not impress the user experience. Since the thread is not suspended, is the small partner afraid to reclaim the objects that should not be recycled? To avoid this problem, there is a third step.

Re-tagging requires STW, but what does it matter? The token is re-tagged just to modify the object that has changed in the previous step. With this step, it is not afraid to reclaim the objects that should not be recycled. Moreover, since this step only modifies the result of the previous step, the STW time is quite short and has little effect on the user .

The final step is to eliminate the concurrency, and this step does not need to be STW, just to clear up some objects that are not on the "network".

In this case, you should know how the collector can do the shortest pause time. With a short STW time Mark and a mark that does not need to be STW, the scope of the third step tag is greatly reduced (just modify it), and the fourth step does not need to be STW.

It looks perfect, but it still has his flaws: a large number of concurrent operations are used, so it consumes a portion of the CPU's resources , resulting in a decrease in throughput, and when the garbage is removed in parallel, the fourth step, he has the current main thread concurrently executing, so when he recycles, Our main thread will generate new garbage, which is not recycled in this recycling process, and can only wait for the next recovery. This rubbish is also called "floating rubbish".

Here we will put the old collector also finished, do not know how the small partners absorbed digestion. Learn more important or rely on their own efforts and diligence, others can give some limited, their own excavation can find endless!

 

JAVA Old generation collector 10th Section

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.