FAQ
Hi,

golang 1.5 release note states that its gc is written in golang itself. I
am curious how it is written. I mean since golang is a garbage collected
language, doesn't this mean that the new 'gc' would itself need a gc? Is it
written in a subset of golang with only stack allocation, etc to prevent gc
itself generating 'garbage'?

B.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Andy Balholm at Sep 3, 2015 at 3:35 pm
    Is it written in a subset of golang with only stack allocation, etc to prevent gc itself generating 'garbage’?
    Yes, that’s basically how it’s done. The runtime, including the GC, is compiled with special options; among other things, the compiler’s escape-analysis system gives an error when a value “escapes” instead of allocating it on the heap.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
    For more options, visit https://groups.google.com/d/optout.
  • Ian Lance Taylor at Sep 3, 2015 at 3:39 pm

    On Thu, Sep 3, 2015 at 1:49 AM, wrote:
    golang 1.5 release note states that its gc is written in golang itself. I am
    curious how it is written. I mean since golang is a garbage collected
    language, doesn't this mean that the new 'gc' would itself need a gc? Is it
    written in a subset of golang with only stack allocation, etc to prevent gc
    itself generating 'garbage'?
    More or less, yes. The entire runtime package is compiled in a mode
    in which the compiler refuses to implicitly allocate memory. The
    runtime package can still allocate memory explicitly where possible
    and appropriate, but the compiler won't introduce any memory
    allocation. Then, given that tool, the GC is written very very
    carefully.

    Note that Go is an open source project, so you can look at the
    implementation yourself. Start at runtime/mgc.go.

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 3, '15 at 3:23p
activeSep 3, '15 at 3:39p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2023 Grokbase