From: James Edward Gray II Date: 2009-12-25T02:00:27+09:00 Subject: Re: FFI Memory Leak On Dec 23, 2009, at 11:26 PM, John Mettraux wrote: > 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. Yeah, those do seem to work. Awesome. Thanks for the help! James Edward Gray II