Hello.

I found memory leak when FFI callback and ref value.
I checked Poly/ML 5.8 and 5.7.
Simple code for reproduce the memory leak is attached.

To prevent the memory leak I clean ref value (see comment in example).
But It must do the garbage collector, is it? At least MLton have not
this problem.


Result of run of example code:

Without clean ref value (The memory leak is)
USER   PID %CPU %MEM    VSZ    RSS TT  STAT STARTED    TIME COMMAND
nick 19855 91,8  9,7 305016 289452  6  S+   16:53   0:17,94 poly --script cb-po


With clean ref value
USER   PID %CPU %MEM   VSZ   RSS TT  STAT STARTED    TIME COMMAND
nick 19862 65,3  0,6 32632 17476  6  S+   16:54   0:10,77 poly --script cb-poly

Best, Nick.
#include <string.h>
void foo (int n, void (*fn) (char *, size_t) ) {
	char *s = "hello ";
	while (n--) {
		(*fn)(s, strlen(s));
	}
	return;
}

Attachment: cb-poly.sml
Description: application/smil

_______________________________________________
polyml mailing list
polyml@inf.ed.ac.uk
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to