------_extPart_001_01C5A7EA.1D7D496D
Content-Type: text/plain;
	charsets-ascii"
Content-Transfer-Encoding: quoted-printable

Hello, can someone explain why GC fails to release "a" in the program
hereunder. When I exchange the lines "a=A.new" and "b=B.new", GC fails
to release b. 

 

PROGRAM

#create some dummy classes

class A;end

class B;end

 

#create two variables, one for each dummy class

a=A.new

b=B.new

 

#store the object_id's for these object to check if these are still
present

bid=b.object_id

aid=a.object_id

 

#check which objects can still be found

ObjectSpace.each_object{|obj|puts("a still found") if
obj.object_id==aid;puts("b still found") if obj.object_id==bid}

puts("")

 

#set both objects to nil and do garbage collection

b=nil

a=nil

GC.start

 

#check again which object are still present. Both a and b should be
gone, but that is not the case

ObjectSpace.each_object{|obj|puts("a still found") if
obj.object_id==aid;puts("b still found") if obj.object_id==bid}

 

 

OUTPUT:

gfannes@ivon gruby $ ruby test.rb

b still found

a still found

 

a still found

gfannes@ivon gruby $

 

Greetings,

Geert


------_extPart_001_01C5A7EA.1D7D496D--