Garbage collector

View: New views
2 Messages — Rating Filter:   Alert me  

Garbage collector

by Paolo Redaelli :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I was wondering if it is indeed possible to implement a garbage
collector in Eiffel itself.
AFAIK "disposing" could be implemented using extensively internals;
creation is still impossible to hack at Eiffel level AFAIK.
Beside the obvious support required by the compiler to customize object
creation from Eiffel, is there any specific reason to keep the GC
implemented in C?

Now, to add some spice to the discussion, a thread safe runtime could
allow the GC to run as an underground thread, couldn't it... well,
whatever thread safe means 8-P

/me this evening will dig programming books on thread safety.


Re: Garbage collector

by Frederic Merizen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I was wondering if it is indeed possible to implement a garbage
> collector in Eiffel itself.

As you said, you wouldn't be able to change the allocator called from
create instructions/expressions. On the other hand, a factory could use
`from_external' to allocate memory for Eiffel objects from Eiffel. You
could probably get introspection to work for detecting live objects (in
the mark phase of a garbage collector), presumably slowly. Caveat:
creating `TYPED_INTERNALS' object from the garbage collector smells funny
(although I've been toying with for quite some time the idea of changing
INTERNALS to make a clever implementation possible where no actual object
needs to be allocated for the TYPED_INTERNAL).

> Beside the obvious support required by the compiler to customize object
> creation from Eiffel, is there any specific reason to keep the GC
> implemented in C?

Actually, it's an idea I've been entertaining for years. The GC is a
complex piece of software that would really benefit from contracts. The
reason I haven't done it (yet?) is that it takes a lot of work to design a
clean Eiffel interface for the beast, and yet more work to actually
implement it. Actually, one of the reasons I Wrote the introspection
support was to take a first stab at exposing the Eiffel runtime to the
Eiffel code.

I don't think I'll be able to contribute a lot to 'GC in Eiffel' project,
should you take it up -I already have too many projects on ice- but I'll
definitely be interested.

Cheers
--
Frederic Merizen