[gambit-list] How allocate u8vectors from C safely&without memory leaks? (Noted ___EXT(___alloc_scmobj)(___sU8VECTOR, len, ___MOVABLE0) leaks 100%, that's used by the sqlite ffi etc.)

Mikael mikael.rcv at gmail.com
Sun Jun 16 09:15:34 EDT 2013


For a side note, this one leaks too - ___release_scmobj does not fix it.

(##gc-report-set! #t)
(for-each (lambda (x) ((c-lambda () scheme-object "___result =
___EXT(___alloc_scmobj)(___sU8VECTOR,10000,___MOVABLE0);
                                                   if
(!___FIXNUMP(___result)) ___EXT(___release_scmobj) (r);
                                                   ")))
          (string->list (make-string 100000))
(##gc)



While I don't know if the

___result = ___EXT(___alloc_scmobj)(___sU8VECTOR,len,___STILL);
if (!___FIXNUMP(___result))  ___still_obj_refcount_dec(___result);


variant suggested in the previous email is really safe & complete,
experience til now seems to say it's alright.

Brgds

2013/6/16 Mikael <mikael.rcv at gmail.com>
..

> *Fix, duno if safe & complete*
>
> (##gc-report-set! #t)
> (for-each (lambda (x) ((c-lambda () scheme-object "___result =
> ___EXT(___alloc_scmobj)(___sU8VECTOR,10000,___STILL);
>                                                    if
> (!___FIXNUMP(___result)) ___still_obj_refcount_dec (___result);
>                                                    ")))
>           (string->list (make-string 100000))
> (##gc)
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130616/928cbff4/attachment.htm>


More information about the Gambit-list mailing list