strong ref from weak ref?

N

Navindra Umanee

Hi,

I would like to have a lookup table with WeakRefs to various
structures so that they can be GC'ed if Ruby is low on space.

However, when I look up a structure, I want to get a strong ref from
the WeakRef so that I don't have to worry about it being collected
while being used.

I can seem to find any methods to get the strong ref from the WeakRef.
Maybe this can be done by having a second lookup table with WeakRefs
pointing to strong refs. I don't know if that will mess up the GC
though.

Any ideas?

Thanks,
Navin.
 
F

Florian Gross

Navindra said:
I would like to have a lookup table with WeakRefs to various
structures so that they can be GC'ed if Ruby is low on space.

However, when I look up a structure, I want to get a strong ref from
the WeakRef so that I don't have to worry about it being collected
while being used.

I think WeakRef#__getobj__ will do what you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top