This procedure accepts no parameters and appears to create XML using the DOM based on the contents of several temp-tables (I'm inferring that they are temp-tables from the "tt" prefix.)
These temp-tables are of unknown size.
A sub-procedure is called but we don't have that code.
No visible attempt is made to clean up the widgets which get created along the way.
The combination of DOM and poor memory management is a recipe for various out of memory errors. Such as those described.
I would do as Stefan suggests and identify the particular line which is failing. Additionally I would add some debugging to log the size of the temp-tables and determine if the error is related to the amount of data being processed. Because you are not cleaning up your handles that may be a cumulative thing -- rather than being related to the size of any one temp-table it could be related to the total amount of stuff processed over the life of the session.