Subject:
Re: [ruby-ffi] freeing memory after FFI::MemoryPointer.new
From:
Alvaro
Date:
1/4/11 2:27 PM
To:
ruby-ffi@googlegroups.com

2011/1/4 Chuck Remes <cremes.devlist@mac.com>:
>
> On Jan 4, 2011, at 2:11 PM, Alvaro wrote:
>
>> Hi,
>>
>> I wonder if there is something that needs to be done after call to
>> FFI::MemoryPointer.new
>> to free the memory, my extension has memory leaks and it only happens
>> with the binding
>> and not with the original C lib.
>
> When a MemoryPointer goes out of scope, the garbage collector will free the native memory. Therefore, you likely still have references to these pointers hanging around since they are not collected.
>
> You may want to try running your extension under rubinius and/or jruby to see if the leaks persist in those environments. They may also give you more hints as to where the problem is.
>
> If you are running on OSX, you may also want to try using the "leaks" program (command line) which will examine a program's heap and report on all leaks it finds.
>
> cr
>
>

I will try other rubies to see what happen, thanks for your answer.

-- Alvaro