3 ms·
What other popular languages use a conservative GC, though?
by mikeash 15y ago
What other popular languages use a conservative GC, though?
- sausagefeet 15y agoI believe Mono uses Boehm GC, which is conservative: http://www.mono-project.com/Mono:Runtime#Mono.27s_use_of_Boehm_GC http://www.mono-project.com/Mono:Runtime#Mono.27s_use_of_Boe...
- kingkilr 15y agoThey've introduced S-Gen which is a good, precise, generational collector. I don't know if it's the default, but it is considered production ready IIRC.
- jstedfast 15y agoIt'll be the default in Mono 3.0 (or 2.12, whatever we decide to call it). Currently, in Mono 2.10, Boehm GC is the default, although we've been using SGen for our commercial products (which is why we feel that SGen is now ready to be the default).
- jstedfast 15y agoAnd yet Mono works fine in environments with < 512MB of RAM, even when using Boehm GC :-)
- chc 15y agoThat's because the conservative GC issue is separate from the low-RAM issue.
- chc 15y agoLast I checked, Ruby uses a conservative GC. It uses one bit of every variable as a flag to unambiguously identify pointers, so that's a free pass on the integer-aliasing problem Go experiences. (Of course, the problem described in the OP is different and has to do with how Go allocates memory.)
- mikeash 15y agoMaybe I'm confused about what's going on, but if Ruby unambiguously identifies pointers at runtime, and the GC takes advantage of that, wouldn't that not be a conservative GC?
- chc 15y agoThe point is that there isn't any integer that looks like a pointer — odd numbers are immediate, even are addresses — so Ruby's GC is spared from having to figure it out. It avoids the problem as a side effect of a performance optimization in the language implementation, so the GC doesn't have to be smarter. The compromise is in losing a bit of integer precision. But now that I think twice about it, I suppose I might kind of be splitting hairs.
- mikeash 15y agoWell, I'm not sure what you call it, but if you can't even have an integer that looks like a pointer, then you effectively don't have a conservative collector. The important distinction is whether an object can be kept alive through a false reference, and it sounds like it definitively can't in this case.