[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Memory Issues with C extensions and each blocks

Zed A. Shaw

4/16/2005 4:24:00 PM

Hi,

While writing the Ruby/Odeum C extension I ran into this problem where
object allocated inside an each block did not get collected until the
each block exited.

At first I thought it was because I had implemented the each block in C
and I wasn't doing something right. But then I got rid of the C each
block and used a Ruby each in the test scripts and saw the same problem.
Objects will get allocated from the C extension, build up during the
each execution, and then at the end they get properly collected. I
verified this by having the registered free functions print a message to
stdout.

My current solution is to have an explicity "close" method on the one
object that offends the most and warn the users, but I'm wondering if
there's some C extension magic that I'm misssing.

Any help is greatly appreciated.

Zed A. Shaw
http://www.ze...



1 Answer

Tilman Sauerbeck

4/16/2005 4:32:00 PM

0

Zed A. Shaw <zedshaw@zedshaw.com> [2005-04-17 01:24]:
> My current solution is to have an explicity "close" method on the one
> object that offends the most and warn the users, but I'm wondering if
> there's some C extension magic that I'm misssing.

You're probably not missing anything - your code shouldn't break if the
GC isn't called in specific intervals or at a specific time, since stuff
like this isn't defined.

So, using a "close" method seems to be the best way to handle this.

I don't know of any "extension magic" regarding your problem either.

--
Regards,
Tilman