Garbage collection when compiling to C
Posted
by
Jules
on Stack Overflow
See other posts from Stack Overflow
or by Jules
Published on 2011-01-05T11:50:00Z
Indexed on
2011/01/05
11:53 UTC
Read the original article
Hit count: 267
What are the techniques of garbage collection when compiling a garbage collected language to C? I know of two:
maintain a shadow stack that saves all roots explicitly in a data structure
use a conservative garbage collector like Boehm's
The first technique is slow, because you have to maintain the shadow stack. Potentially every time a function is called, you need to save the local variables in a data structure.
The second technique is also slow, and inherently does not reclaim all garbage because of using a conservative garbage collector.
My question is: what is the state of the art of garbage collection when compiling to C. Note that I do not mean a convenient way to do garbage collection when programming in C (this is the goal of Boehm's garbage collector), just a way to do garbage collection when compiling to C.
© Stack Overflow or respective owner