[plt-scheme] Garbage collection woes
Hi, I've been using scheme for almost a year now, and I'm loving it. I
find that even though I can still work in other languages (and in fact
can program somewhat better than before I learned scheme), I am
constantly seeing things which would be ten times easier to implement
in scheme =).
I'm writing a simple OpenGL game involving up to a thousand objects
moving in 2D. I am having GC troubles though, and am getting
noticeable (almost 1/10 of a second) pauses every few seconds. When I
dump memory stats on program quit, I see that the number of pauses
roughly corresponds with the number of mature-space collections. I am
using mzscheme v371[3m].
I remember looking into the implementation of the 3m garbage collector
a month or so ago, and seeing that when a nursery collection is done,
all of the surviving objects are placed in mature space, regardless of
their age.
My game involves some objects which survive multiple frames (the
moving game objects), but a lot more objects which survive only up to
one frame (intermediate vectors used for calculations, lists produced
by map, etc.), which is about 1/60 of a second. However, if I
understand correctly, if a nursery collection is triggered while the
game is updating for a new frame, the mature space is going to be
polluted with a lot of objects which don't really belong there.
This is a particular problem for me because although the young
collections do not cause noticeable pauses, mature ones do. Having a
mature collection run every once in a while is okay, but at every few
seconds it gets annoying fast =(.
With my limited knowledge of garbage collector implementation, I would
think that a fix as simple as only moving objects to mature space
after they survive X number of nursery collections would help this
tremendously.
How difficult would it be to change the garbage collector to do
something like this, and how likely is it that such a feature will be
implemented?
Henk
P.S.: I suppose having the program be able to ask that mzscheme permit
it to use more memory before collecting would help as well. I know
that the smarteiffel compiler had three memory modes, one of which
would try to keep the memory usage low, one which kept it at
reasonable levels, and one which would gobble memory until it actually
ran out before collecting.