From: John Mettraux Date: 2009-12-24T14:26:28+09:00 Subject: Re: FFI Memory Leak On Thu, Dec 24, 2009 at 12:41 PM, James Edward Gray II wrote: > I've found a memory leak in some FFI code.  I'll give example code below, but I can explain the issue easily enough first. > > When calling a function provided by Tokyo Cabinet, it returns a value in the form of a pointer and a length to read at that address.  The documentation for the function (tchdbget() at http://1978th.net/tokyocabinet/spex-en.html#tchdbapi, if you are interested) warns that the returned region was allocated with malloc() and needs to be free()d.  I can't figure out how to free the value, so there is a memory leak.  What I would like to know is how to free the value at the end of the pointer. Hello, maybe http://gist.github.com/263033 or http://gist.github.com/263034 Seems to work. Merry Christmas, -- John Mettraux - http://jmettraux.wordpress.com