Well, your suggestion of Scalar::Util::weaken worked out perfectly. It was easy to modify the parser items to weaken their link back to the main Formula object. There was also a similar recursive reference within the Context object, and that was also easily fixed. So I think the MathObjects no longer leak memory. I have submitted the changes to the CVS archive, and you should be able to update pg without updating webwork2.
Thanks for the suggestion; it was a big help. I had been worried about those recursive references for a long time, so it is nice to have them fixed.