[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Extensions: Init_extension exists, looking for Deinit_extension

daniel åkerud

2/4/2008 5:33:00 PM

[Note: parts of this message were removed to make it a legal post.]

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

3 Answers

Jason Roelofs

2/4/2008 7:16:00 PM

0

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 Feb 4, 2008 12:32 PM, daniel =E5kerud <daniel.akerud@gmail.com> wrote:
> 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 rele=
ase
> the resource with the garbage collector. Is there something for this?
>
> /D
>

Jan Dvorak

2/4/2008 9:24:00 PM

0

On Monday 04 February 2008 20:16:22 Jason Roelofs 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

daniel åkerud

2/7/2008 7:44:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

On Feb 4, 2008 10:24 PM, Jan Dvorak <jan.dvorak@kraxnet.cz> wrote:

> On Monday 04 February 2008 20:16:22 Jason Roelofs 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
>
>
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