/sys/doc/ Documentation archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inferno and UNIX / to C or to GC, that is the question.

Berry Kercheval wrote:
>  > and C is not really
>  > compatible with garbage collection.
> I know this isn't really about Inferno,
> but I feel constrained to point out
> that garbage collection CAN work quite well with C,...

In the typical case, Berry is right, but it's possible
to break any garbage collector in C with programs that
are unusual, though not pathological.

* A program that allocates lots of circular lists will typically
never see them collected.  Likewise for doubly-linked lists.

* A large program filled with random numbers can make it
unlikely that conservative GC will be able to deallocate
anything.   For instance if you have 100MB of floating point
data in a 2GB heap address space, and you allocate space in
64 byte chunks, then any allocated chunk has about even odds
of appearing to be referred to.  If you allocate space in 8KB
chunks, then roughly 99% of the chunks will be uncollectable
[unless you give the GC system hints...].

So, you can't write a strict C implementation
that will guarentee that all legal programs will work.
A C implementation might still be useful, though.