TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Demystifying Garbage Collectors

90 点作者 gmcabrita超过 12 年前

7 条评论

RodgerTheGreat超过 12 年前
If you can look at a word of memory and differentiate pointers from values, garbage collection can become extremely simple. It's a shame that tagged architectures have largely died out.<p>As an experiment, I tried writing a garbage collector which used high-order bits of a word to identify pointers. The result is about a page of code in Forth:<p><a href="http://hastebin.com/raw/gabunowelo.fs" rel="nofollow">http://hastebin.com/raw/gabunowelo.fs</a><p>This example works exclusively with fixed-size "cons pair" allocations, but generalizing to arbitrary-sized allocations only increases the complexity of the system slightly. Obviously this bitflag technique is not "safe" in general, as arbitrary values on the stacks could produce false positives, but it's easy to imagine a 33-bit or 65-bit architecture that provided the necessary hardware support without such caveats.
评论 #4643805 未加载
评论 #4643533 未加载
评论 #4643532 未加载
microtherion超过 12 年前
"Garbage Collection" by Jones &#38; Lins was, in my opinion, an excellent book back in the day: <a href="http://tinyurl.com/8lrveqm" rel="nofollow">http://tinyurl.com/8lrveqm</a><p>I noticed that Jones has a new book (The Garbage Collection Handbook) out now, which presumably is even better: <a href="http://tinyurl.com/8nl6con" rel="nofollow">http://tinyurl.com/8nl6con</a>
评论 #4643508 未加载
pcwalton超过 12 年前
"It is very likely that the Rust language will go with a similar model [per-thread instead of global garbage collection]."<p>Rust is using this model today.
评论 #4643498 未加载
batgaijin超过 12 年前
I think a really cool tactic is racket's places, which basically creates individual zones running their own module with their own gc (but objects shared between cores don't take up extra space, there is a global table or something).
评论 #4643568 未加载
评论 #4644544 未加载
mseepgood超过 12 年前
Nice article. What I didn't understand: How does a conservative GC without type information know where the references are in an object? E.g. given this object:<p>struct {<p>double a; // 64 bit<p>short b // 16 bit<p>int c, d; // 32+32 bit<p>FooPtr e; // 64 bit<p>int f; // 32 bit<p>BarPtr g; // 64 bit<p>}<p>Does it assume that all fields are aligned to 64 bit boundaries? Does it potentially consider a double to be a pointer? And how does it know where to stop looking for references without knowing the size of the object?
评论 #4644094 未加载
评论 #4644018 未加载
评论 #4644021 未加载
weirdkid超过 12 年前
Oh, THOSE garbage collectors. I was rather hoping this would be an exposé on the secret tech employed by curbside trash collection companies.
keikun17超过 12 年前
i see alex is this busy. no wonder alex hasn't been online in steam recently