From: Jez Stephens Date: 2006-08-27T23:45:34+09:00 Subject: Keep track of all instances of a class without losing GC? Hi, I want to be able to keep track of all instances of a class using something simple like this: Class Thing @@allthings = [] def initialize @@allthings.push self end end However an obvious drawback to this approach is that instances of this class will never be garbage collected due to the reference held in @@allthings. Is there a way to make it so this reference in @@allthings "doesn't count", so to speak? Or is there a better way of doing it? Thanks for your help -- Posted via http://www.ruby-forum.com/.