[MacRuby-devel] MacRuby and ARC was: Advice for Total Tyro

Perry E. Metzger perry at piermont.com
Tue Oct 18 05:44:56 PDT 2011


On Tue, 18 Oct 2011 10:04:37 +0200 Laurent Sansonetti
<laurent.sansonetti at gmail.com> wrote:
> Hi Perry,
> 
> On Tue, Oct 18, 2011 at 12:07 AM, Perry E. Metzger
> <perry at piermont.com> wrote:
> > On Mon, 17 Oct 2011 13:44:56 -0700 Matt Aimonetti
> > <mattaimonetti at gmail.com> wrote:
> >> See my earlier reply, basically, you are right, it is technically
> >> possible to change the way MacRuby works to use an automatic
> >> reference counting approach.
> >> But it's far from being trivial.
> >
> > Wouldn't reference counting radically change the behavior of Ruby
> > in the presence of cycles though? It would no longer be exactly
> > the same language -- libraries that used cyclic data structures
> > internally would need to be rewritten.
> >
> 
> Some people managed to have ref counting GCs that are able to deal
> with cycles.

These techniques fall into a couple of categories: run a real GC every
once in a while, or require user code changes (some of which could
reduce safety guarantees).

The latter technique in conjunction with reference counting is
probably a great compromise in a C or Objective C context -- the
environment already does lots of manual memory management and is
already not safe. For something like Ruby, though, it feels much less
clean.

Using reference counting to reduce the number of sweep passes for a
real GC would probably be fine, of course. That might reduce MacRuby's
real memory runtime footprint a lot, too, as transiently used objects
would vanish very fast. If I recall correctly, almost all objects
never have more than one reference and die extremely fast.

Perry
-- 
Perry E. Metzger		perry at piermont.com


More information about the MacRuby-devel mailing list