Am Sonntag, 20. Mai 2007 21:51 schrieb Bram Geron: > Bram Geron wrote: > > The patch in <parrot.solution1.patch> fixes the problem for me. > > I realized that contexts currently initially have a ref_count of 0, if > they're not used as :outer targets for other subs. So in 'normal' > situations, the caller's context's ref_count now drops from 0 to -1 in a > tail call, and since -1 != 0 the caller's context will never be freed, > resulting in a memory leak. Attached <parrot.solution1.updated.patch> > should fix that.
It's likely simpler to start all context refcounts equally with 1. This would probably reduce the current special refcount handling. But it would need some changes, which is easily greppable I presume. > Still, I'm left with a question. How can we DOD a closure? To me it > seems that once a closure exists, it references its context. Often the > context is still left in a register, so the context references the > closure PMC, which in turn references the closure. Because we use > reference counting in these cases, no count ever drops to zero, and they > all live forever. Think of (closure) contexts, which were created in "eval"-ed code. When the outer context ceases to exist, the inner context can be collected. All other closure context is of course persistent. leo