[m-dev.] New conservative GC

Jonathan Morgan jonmmorgan at gmail.com
Mon Apr 16 12:22:24 AEST 2007


On 4/12/07, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
> Ralph Becket, Thursday, 12 April 2007:
> > Can someone give me any pointers as to where I should start looking in
> > the Mercury code for adding a .hgc grade?  In particular, I need to
> > ensure that
> > (1) the collector is initialised at the start-of-day;
> > (2) heap allocation is handled correctly;
> > (3) any mutable data is identified;
> > (4) tail-call-modulo-cons and CTGC are disabled (they are incompatible
> >   with assumption (b)) when HGC is being used.
>
> I forgot to include
>
> (5) any out-of-heap regions (global variables, the trail, etc.) that can
> contain heap pointers need to be pointed out to the collector.

This sounds promising.  However, I have a few questions about it, and
about the general Mercury memory management policy.

Quite a few of the libraries in extras (e.g. curses and Tk bindings)
redefine malloc and friends in terms of GC_malloc and friends.

If malloc is re-defined in terms of HGC's malloc, then most uses of
malloc in these libraries will be allocating (potentially) mutable
data structures.  I imagine that this would remove quite a few of
HGC's advantages.  On the other hand, if it is not done, then HGC may
not be aware of memory references, causing it to incorrectly collect
data.

>From the Reference Manual (14.8 Memory Management):
Future Mercury implementations may use non-conservative methods of
garbage collection. For such implementations, it will be necessary to
explicitly register pointers passed to C with the garbage collector.
The mechanism for doing this has not yet been decided on. It would be
desirable to provide a single memory management interface for use when
interfacing with other languages that can work for all methods of
memory management, but more implementation experience is needed before
we can formulate such an interface.

I suggest that this might be the right time to work out a memory
management interface.  It sounds to me that the registering of
pointers that have been passed to C is likely to be the best way of
interfacing a Mercury hgc grade with an existing C library like Tk
that holds references to Mercury data structures (typically closures
for callback registration).

Jon
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list