Various garbage collection algorithms (ii) tag-purge (Mark-sweep) algorithm _ Algorithm data structure

Source: Internet
Author: User
Tags garbage collection
Tag-Purge (Mark-sweep) algorithm

The first practical and perfect garbage collection algorithm was proposed in 1960 and successfully applied to the Lisp language's tag-purge algorithm by people such as J. McCarthy. Still take the napkin as an example, the tag-purge algorithm is executed as follows:

In the course of the lunch, all the people in the restaurant took their napkins according to their needs. When a garbage collector wants to collect discarded napkins, it will make all the diners stop and then, in turn, ask everyone in the restaurant: "Are you using a napkin?" Which paper napkin do you use? "The robots mark the napkins that people are using, according to everyone's answers." At the end of the inquiry, the robot was in the restaurant looking for all the scraps of paper napkins that had been strewn around the table (which were apparently used scrap napkins) and threw them into the bin.

As its name implies, the execution of the tag-purge algorithm is divided into two major phases, "tag" and "purge". This step-by-step approach lays the thought foundation of the modern garbage collection algorithm. Unlike the reference counting algorithm, the tag-purge algorithm does not require running the environment to monitor each memory allocation and pointer operation, and as long as the pointing of each pointer variable is tracked in the "mark" phase-the garbage collector, which is implemented in a similar way, is often referred to as the tracking collector (tracing Collector)

Along with the success of the Lisp language, the tag-purge algorithm also has a shine in most of the early Lisp environments. Although the initial version of the tag-purge algorithm still appears to be inefficient today (marking and purging is two time-consuming process) and many other flaws, but in the discussion that follows, we can see that almost all modern garbage collection algorithms are a continuation of the mark-purge idea, and only that, J. McCarthy Other people's contribution to garbage collection technology is no less than their Lisp language achievements.

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.