The recommended way to work with tDOM is to use the idiom
dom parse $xml doc
instead 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 [1]
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.
-g
[1] http://tdom.github.io/dom.html