[4suite] Replace Child problems (fwd)
Uche Ogbuji
uche.ogbuji at fourthought.com
Mon Sep 11 02:33:06 MDT 2000
Nicolas Chauvat wrote:
> What we have is an engine that manipulates XML documents and uses
> "plug-ins" to modify them. The engine is not supposed to stop running. We
> will not have full control over the plug-ins. Others will write them.
> When we finish a sequence of transformations (made by plug-ins), we want
> to get rid of the intermediary documents. We do not know for sure that the
> plug-ins cleanly released all unneeded nodes. If there are cycles, we leak
> memory.
>
> What we did was to make the document maintain a list of all its nodes
> (even "free" nodes that were created but not attached to a parent), in
> order to make sure that when we release a document, all its nodes (even
> the ones that remain because of a badly behaved plug-in) are
> released.
>
> That wouldn't happen if it wasn't for python's garbage collector that
> works with ref counts and let autonomous node communities live their lives
> alone...
Ouch! I guess you don't have much choice but to keep your dictionary of
nodes until Python 2.0 is ready for prime time.
I should note that if others can write sloppy code for your long-running
server, there are many cases in which they could cause circular
references and thus leak memory without any help from DOM. DOM just
makes it a bit easier to do so.
Hopefully you are able to do this node-registration trick by
sub-classing the Document class, so that you can migrate to the new
release we're preparing with minimum difficulty. We have fixed _many_
other bugs.
Good luck.
--
Uche Ogbuji Principal Consultant
uche.ogbuji at fourthought.com +1 303 583 9900 x 101
Fourthought, Inc. http://Fourthought.com
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python
More information about the 4suite
mailing list