Forum OpenACS Q&A: Re: Need some tips about memory allocation

Collapse
Posted by Gustaf Neumann on
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

Collapse
Posted by Antonio Pisano on
Thanks for the pointers guys! I revised the code to eliminate the leaks.

I have also managed to give an extra 256MB to the machine and all went smooth today... I guess this fixed the issue.