Some of our memory problems seem to be strange interactions between PObjs allocated out of constant pools, garbage collection, and freezing/thawing PBC (not to mention the interaction of HLLs).
PObjs allocated out of constant pools persist in memory. They get marked (sometimes, but not always), but the garbage collector doesn't sweep the constant pools to recollect them. This is not normally a problem for most constant PObjs. It's mostly fine for strings, and it's fine for PMCs that do not have a special mark() vtable entry. PMCs that *do* need a special mark() are troublesome; they may contain pointers to non-constant PObjs that *do* need live marking, lest they get swept away during the second half of GC. If these constant PObjs don't get marked, there's a problem. (I'm not entirely sure that copy-on-write strings work with constant strings; it seems as though if we're not very careful about managing refcounts there, the string buffer could go away even if the string header sticks around. Something's fishy about that system somehow, but I don't have a good test for it.) Allison suggested "Hey, why not register all constant PMCs when you grab a new constant PMC header?" and that's an easy patch to write. Another option is to walk through the constant PMC pool at the start of the mark phase to look for PMCs with the mark flag set and call those directly. (That could simplify some other operations; this could be the root set itself, but that's a mere detail.) Another concern to me is that I can't convince myself that the "HEY I AM A CONSTANT" flag gets stored in PBC when we freeze such a PMC or gets restored when we thaw that PMC. If that metadata doesn't persist, then a perfectly constant PObj when run from PIR will have weird and incorrect GC characteristics when run from PBC. I think we may be seeing this with Lua. (Of course, running Lua is difficult enough as it is that I'm never sure if the failures I see there are because I'm running it from the wrong directory or the wrong compiler. It's very much not easy to debug as it is now.) I welcome thoughts and especially explanations and help on this. I've been tracking down these issues off and on for weeks, and in plenty of detail for most of the past week. Help! -- c