[plt-scheme] another game: pacman

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Aug 22 12:30:16 EDT 2006

The foreign interface is one of the main problem when moving from the
conservative GC to 3m.

You have to be aware of the GC in both cases (eg, protect some memory
blocks from the GC), but in 3m things can get even more problematic --
memory blocks can move to someplace else.  Obviously, if you allocated
some memory for a foreign library, and the GC has moved it, the
library may not be too happy about it if it has any references to the
now-invalid location.

The "simple" solution is to use raw malloc, so the allocated memory is
invisible to the GC (so 3m will not move it).  You can hold a
reference to the allocated block in some Scheme value, and put a
finalizer on the Scheme value that will free the extra memory when
it's GCed.

(The good news is that code that works on 3m will work using the CGC
too.)


On Aug 22, Jon Rafkind wrote:
> 3m and Allegro( the underlying graphics library ) dont like each other,
> yet..
> 
> Noel Welsh wrote:
> > In the interests of science I tried Pacman both with and
> > without 3m.  I originally installed it without 3m.
> >
> > ~/data/tmp/pacman-0.1> mzscheme3m -f pacman.ss
> > Welcome to MzScheme3m version 352.2, Copyright (c)
> > 2004-2006 PLT Scheme Inc.
> > Shutting down Allegro due to signal #11
> > Segmentation fault
> >
> > ~/data/tmp/pacman-0.1> mzscheme -f pacman.ss
> > Welcome to MzScheme version 352.2, Copyright (c) 2004-2006
> > PLT Scheme Inc.
> > ... Pacman runs ...
> >
> > N.
> >
> > --- Matthew Flatt <mflatt at cs.utah.edu> wrote:
> >
> >   
> >> At Mon, 21 Aug 2006 23:46:47 +0300, tomi.neste at netikka.fi
> >> wrote:
> >>     
> >>> So, am I alone with my problem or is this the expected
> >>>       
> >> behaviour and is there
> >>     
> >>> any way to improve/tune the gc performance?
> >>>       
> >> Are you using the 3m variants of MzScheme, MrEd, etc.?
> >> (Apologies if
> >> you said before and I missed it.)
> >>
> >> Matthew

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.