[m-users.] Too Slow
Delmas Buckley
rbuckley at ieee.org
Fri May 1 14:25:10 AEST 2015
Hi,
Matthias, I may have encountered a
failure-to-release-no-longer-needed-memory in a test I ran that I'll review
in the morning, as I'm very tired now.
Best regards,
Robert Buckley
On Thu, Apr 30, 2015 at 5:22 PM, Peter Wang <novalazy at gmail.com> wrote:
> Hi,
>
> On Thu, 30 Apr 2015 18:54:29 +0100, Matthias Guedemann <
> matthias.guedemann at googlemail.com> wrote:
> >
> > I'd be happy to learn more on using FFI. In particular, I think my
> > approach is heavy on memory leaks. Every time a new mp_int is created,
> > memory is allocated which is never(?) freed. How does one handle this in
> > Mercury normally when using FFI?
>
> You should allocate the mp_ints like this:
>
> Mp_Int = MR_GC_NEW_ATTRIB(mp_int, MR_ALLOC_ID);
>
> For the string in mp_to_string you should use
>
> MR_allocate_aligned_string_msg(S, length, MR_ALLOC_ID);
>
> or other macros in mercury_string.h
>
> You should add the attribute `thread_safe' to all of the foreign procs.
>
> Peter
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://www.mercurylang.org/lists/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20150430/192d0a94/attachment.html>
More information about the users
mailing list