<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming Languages on Blogs</title><link>https://hbisheng.github.io/blogs/programming-language/</link><description>Recent content in Programming Languages on Blogs</description><generator>Hugo</generator><language>en-us</language><copyright>Bisheng Huang</copyright><lastBuildDate>Thu, 28 Dec 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://hbisheng.github.io/blogs/programming-language/index.xml" rel="self" type="application/rss+xml"/><item><title>(Notes) Go GC algorithm</title><link>https://hbisheng.github.io/blogs/programming-language/go-gc/</link><pubDate>Thu, 28 Dec 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/programming-language/go-gc/</guid><description>&lt;p&gt;Go is a language with automatic GC (garbage collection). The GC process uses a tri-color mark-and-sweep algorithm.&lt;/p&gt;&#10;&lt;h3 id="tri-color-algorithm"&gt;Tri-color algorithm&lt;/h3&gt;&#10;&lt;p&gt;&lt;strong&gt;Two stages&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Mark phase: mark objects that are reachable. It&amp;rsquo;s a directed graph problem. You start from a set of root objects (e.g. global variables, pointers from the stack to the heap) and process all objects referenced directly or indirectly.&lt;/li&gt;&#10;&lt;li&gt;Sweep phase: reclaim objects that are not reachable. This doesn&amp;rsquo;t happen synchronously but amortizes over new memory allocations.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;&lt;strong&gt;Three colors&lt;/strong&gt;&lt;/p&gt;</description></item></channel></rss>