From: Florian Weber Date: 2005-10-22T00:14:42+09:00 Subject: Re: Removing a class for good from ObjectSpace > I think this is the same or a similar issue the Rails guys were dealing > with at the conference with their memory leak. > > One solution I know of is to remove the constant and then set it to an > empty class: > > Object.class_eval do > remove_const :Foo > const_set :Foo, Class.new { } > end > GC.start Thanks, Paul. Unfortunately it doesn't seem to work for me: class Bar end class Foo < Bar end Object.class_eval do remove_const :Foo const_set :Foo, Class.new(Bar) { } end GC.start class Foo < Bar end ObjectSpace.each_object(Class) do |klass| puts klass if Bar > klass end It still prints out both Foo classes in this case. Any ideas?