[m-users.] Mercury Memory Management

Zoltan Somogyi zoltan.somogyi at runbox.com
Fri Mar 14 18:15:30 AEDT 2014



On Thu, 13 Mar 2014 22:36:01 -0700, Haitao Zhang <zhtprog at gmail.com> wrote:
> I see. Thanks for the tip. So what if one supplies a heap manager in place
> of Boehm GC? All this manager does is to track Mercury heap allocated
> structures as if Mercury uses a separate heap. Then when returning from
> Mercury the caller manually frees all Mercury structures. Anything that
> needs to be preserved is done through the CFFI using the regular heap. This
> is like a thread execution model with separate heap and shared memory for
> communication. Would this work?

Yes, that approach can be made to work, with a moderate though
nontrivial amount of work, if you are ok with identifying exactly what
falls into the category of "anything that needs to be preserved"
outside Mercury. Teaching the compiler to allocate different terms
differently would be a *huge* amount of work.

Zoltan.





More information about the users mailing list