[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

ObjectSpace::_id2ref and GC

Ara.T.Howard

6/6/2005 6:04:00 PM

2 Answers

Yukihiro Matsumoto

6/6/2005 11:00:00 PM

0

Hi,

In message "Re: ObjectSpace::_id2ref and GC"
on Tue, 7 Jun 2005 03:04:24 +0900, "Ara.T.Howard" <Ara.T.Howard@noaa.gov> writes:

|it seems like doing something like
|
| id = object.object_id
|
|and then later
|
| value = ObjectSpace::_id2ref id
|
|one is gambling that the original object has not been gc'd and that the id
|still points to the same object. is this accurate?

I'm sorry I'm not sure I get what you meant. You call

id = object.object_id

and then later

value = ObjectSpace::_id2ref id

the original object may or may not be reclaimed. There's no
guarantee. Unless you check reclamation by finalizer (as in
weakref.rb), you can't tell whether value is the original object or
a recycled object.

matz.


Ara.T.Howard

6/6/2005 11:43:00 PM

0