[m-users.] Too Slow
novalazy at gmail.com
Sat May 2 00:55:20 AEST 2015
On Fri, 1 May 2015 23:23:49 +1000, Mark Brown <mark at mercurylang.org> wrote:
> Unfortunately, libtommath falls into this category - it expects
> mp_ints to be cleared when they're done with. So the code still leaks
> even with the above changes.
It's not very convenient, but libtommath does provide a way to override
the allocation functions that it uses: by defining the preprocessor
symbols XMALLOC/XREALLOC/XCALLOC/XFREE when building the library, e.g.
CFLAGS='-DXMALLOC=MR_GC_malloc -DXREALLOC=MR_GC_realloc \
-DXCALLOC=MR_GC_calloc -DXFREE=GC_free' make
The Mercury binding would not call mp_clear explicitly, but it would be
unnecessary to do so.
Another possibility is to register finalisation functions with Boehm GC
for every mp_int, but that is something to avoid if possible.
More information about the users