Forum OpenACS Q&A: Re: Need some tips about memory allocation
dom parse $xml docinstead of
set document [dom parse $xml]since the former deletes the tdom-managed memory automatically, when the variable doc is freed, the latter not. If doc is not a namespaced variable, aolserver/naviserver will automatically clean it up after the request. In the second variant, you tell tDOM that you want to manage the lifetime of the documents yourself.... and you have to clean it, otherwise you are facing a memory leak. For details, see 
To check potential leaks, use in ds/shell
info command ::dom*0x*If this command returns non-empty, you have likely leaking tDOM nodes and/or tDOM documents.