From: Laurent Sansonetti Date: 2008-02-29T05:36:22+09:00 Subject: Re: [ANN] MacRuby On Thu, Feb 28, 2008 at 2:34 AM, Charles Oliver Nutter wrote: > Laurent Sansonetti wrote: > > Hi, > > > > I am honored to announce the beginning of the MacRuby project! > > > > MacRuby is a version of Ruby that runs on top of Objective-C. More > > precisely, MacRuby is currently a port of the Ruby 1.9 implementation > > for the Objective-C runtime and garbage collector. > > How are you able to implement ObjectSpace without any impact at runtime? Because all objects are being allocated from the same memory zone, so I just have to walk through the zone. (See /usr/include/malloc/malloc.h for more details.) > Do you disable the GC while ObjectSpace is walking? If not, how do you > avoid the possibility that objects may be collected while you are > walking the heap? I have been thinking of this too, it appears that the current code path works well even if a collection occurs right in the middle. I could nevertheless lock the GC during #each_object if there is a problem. It doesn't change the fact that there is no runtime penalty by default (you can use ObjectSpace if you want). Obviously, MacRuby's #each_object is slower, definitely because it returns all objects from the zone, including Objective-C objects too. $ ruby -ve "p ObjectSpace.each_object {}" ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0] 310 $ /usr/local/bin/ruby -ve "p ObjectSpace.each_object {}" MacRuby version 0.1 (ruby 1.9.0 2008-02-18 revision 0) [i686-darwin9.2.0] 8759 $ /usr/local/bin/ruby -ve "framework 'cocoa'; p ObjectSpace.each_object {}" MacRuby version 0.1 (ruby 1.9.0 2008-02-18 revision 0) [i686-darwin9.2.0] 48425 Laurent