I am allocating a resource in Init_extension, that is, when the .so file
is
loaded. I am looking for a way to deallocate this resource even though
no
object has been created with the extension, in other words, I cannot
release
the resource with the garbage collector. Is there something for this?
/D
As you cannot explicitly unload a require, no there’s nothing like
this because it’s not needed. When the ruby interpreter shuts down,
the C runtime / OS cleans up anything opened during execution.
Jason
On Monday 04 February 2008 20:16:22 Jason R. wrote:
As you cannot explicitly unload a require, no there’s nothing like
this because it’s not needed. When the ruby interpreter shuts down,
the C runtime / OS cleans up anything opened during execution.
And if you have any resources you need to clean up at ruby exit, you can
do so
by setting rb_set_end_proc() to your cleanup func.
Jan
On Feb 4, 2008 10:24 PM, Jan D. [email protected] wrote:
Thank you Jan, that was exactly what I was looking for. And Jason,
that is
not at all true. When the Ruby interpreter tears down it does call the
“free” function for all objects created from the extension that has an
“allocate” function. I have global resources that are allocated and
needs
to be released because of reference counting, and which is not done
automatically by windows. I understand that if the Ruby process dies
nothing can save me, but that is not the common case (and in my case
unfortunately requires a service-restart).
Thanks! Happy-time ;D
/D