From: Daniel Berger Date: 2007-10-28T22:13:38+09:00 Subject: Re: JRuby disabling ObjectSpace: what implications? On Oct 28, 12:53 am, Charles Oliver Nutter wrote: > So...I'm writing this to see what the general Ruby world thinks of us > having ObjectSpace disabled by default, enableable via a command line > option (or perhaps through a library? -robjectspace?). .ext\common\win32\registry.rb:569: ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal) ext\dl\test\test.rb:187: ObjectSpace.define_finalizer(fp) {File.unlink("tmp.txt")} ext\tk\lib\multi-tk.rb:493: ObjectSpace.each_object(TclTkIp){| obj| ext\Win32API\lib\win32\registry.rb:569: ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal) lib\cgi\session.rb:299: ObjectSpace::define_finalizer(self, Session::callback(@dbprot)) lib\drb\drb.rb:337:# object's ObjectSpace id as its dRuby id. This means that the dRuby lib\drb\drb.rb:361: # This, the default implementation, uses an object's local ObjectSpace lib\drb\drb.rb:375: ObjectSpace._id2ref(ref) lib\finalize.rb:59: ObjectSpace.call_finalizer(obj) lib\finalize.rb:169: ObjectSpace.remove_finalizer(@proc) lib\finalize.rb:173: ObjectSpace.add_finalizer(@proc) lib\finalize.rb:180: # registering function to ObjectSpace#add_finalizer lib\finalize.rb:192: ObjectSpace.add_finalizer(@proc) lib\irb\completion.rb:152: ObjectSpace.each_object(Module){|m| lib\irb\ext\save-history.rb:69: ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer) lib\shell\process-controller.rb:216: ObjectSpace.each_object(IO) do |io| lib\singleton.rb:23:# ObjectSpace.each_object(OtherKlass){} # => 0. lib\singleton.rb:190: "#{ObjectSpace.each_object(klass){}} #{klass} instance(s)" lib\tempfile.rb:53: ObjectSpace.define_finalizer(self, @clean_proc) lib\tempfile.rb:105: ObjectSpace.undefine_finalizer(self) lib\tempfile.rb:118: ObjectSpace.undefine_finalizer(self) lib\test\unit\autorunner.rb:17: ObjectSpace.each_object(Class) do |klass| lib\test\unit\autorunner.rb:54: :objectspace => proc do |r| lib\test\unit\autorunner.rb:55: require 'test/unit/collector/ objectspace' lib\test\unit\autorunner.rb:56: c = Collector::ObjectSpace.new lib\test\unit\autorunner.rb:80: @collector = COLLECTORS[(standalone ? :dir : :objectspace)] lib\test\unit\collector\dir.rb:13: def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil) lib\test\unit\collector\objectspace.rb:10: class ObjectSpace lib\test\unit\collector\objectspace.rb:13: NAME = 'collected from the ObjectSpace' lib\test\unit\collector\objectspace.rb:15: def initialize(source=::ObjectSpace) lib\test\unit.rb:252: # the ObjectSpace and wrap them up into a suite for you. It then runs lib\weakref.rb:16:# ObjectSpace.garbage_collect lib\weakref.rb:62: ObjectSpace._id2ref(@__id) lib\weakref.rb:74: ObjectSpace.define_finalizer obj, @@final lib\weakref.rb:75: ObjectSpace.define_finalizer self, @@final lib\weakref.rb:98: ObjectSpace.garbage_collect test\dbm\test_dbm.rb:45: ObjectSpace.each_object(DBM) do |obj| test\gdbm\test_gdbm.rb:42: ObjectSpace.each_object(GDBM) do |obj| test\ruby\test_objectspace.rb:3:class TestObjectSpace < Test::Unit::TestCase test\ruby\test_objectspace.rb:10: o = ObjectSpace._id2ref(obj.object_id);\ test\sdbm\test_sdbm.rb:15: ObjectSpace.each_object(SDBM) do |obj| test\testunit\collector\test_dir.rb:62: class ObjectSpace test\testunit\collector\test_dir.rb:81: @object_space = ObjectSpace.new test\testunit\collector\test_objectspace.rb:6:require 'test/unit/ collector/objectspace' test\testunit\collector\test_objectspace.rb:11: class TC_ObjectSpace < TestCase test\testunit\collector\test_objectspace.rb:41: @c = ObjectSpace.new(@object_space) test\testunit\collector\test_objectspace.rb:44: def full_suite(name=ObjectSpace::NAME) test\testunit\collector\test_objectspace.rb:51: TestSuite.new(ObjectSpace::NAME) test\testunit\collector\test_objectspace.rb:83: expected = TestSuite.new(ObjectSpace::NAME) test\testunit\collector\test_objectspace.rb:89: expected = TestSuite.new(ObjectSpace::NAME) test\yaml\test_yaml.rb:1279: ObjectSpace.each_object(Class) do | klass| So, in summary, if we exclude those libraries where only tests are affected, this would affect: win32-registry tk cgi drb finalize irb shell singleton tempfile test-unit weakref Some comments on each of these as they relate to JRuby: win32-registry: You have no hope of implementing this without JNA anyway, unless there's some Java binding I don't know about. Besides, I couldn't tell you why on Earth win32-registry would need a finalizer. tk: No one will care. They'll use SWT or Swing bindings. Besides, you would need JNA. cgi: This could be a problem. Then again, some people say this library should be refactored or tossed. drb: This could be a big deal. finalize: Did anyone even know about this? Does anyone use it? irb: You've got jirb. shell: This could be a problem. singleton: Ditto. tempfile: Meh, I'm guessing Java has its own library for temp files. I never liked the current implementation anyway (which is why I wrote file-temp). test-unit: Already mentioned. weakref: You've stated that Java has its own implementation. Regards, Dan