foo = create_foo(); // create a foo ... // do what we need to do with foo bar->withFoo(foo); // can take its own reference if it needs to ... // do anything else we need to do with foo unref_foo(foo); // we should let go of our reference now
It's the equivalent of the last line that was missing here.
I may misunderstand something, but, if we still need that last line, how it's better than not having a garbage collector at all? Before you needed an explicit free(), now you need an explicit unref() in the same place. If it's still not completely automatic, then what's the gain?
I've comitted a fix for this to CVS; see if things get any better for you. I expect there are more layers to this particular problem.
It still eats memory pretty fast as you go through previews. Maybe slower than before (I haven't measured that before) but not by much. On export, there's no improvement at all (I did measure that before and after).