[Templates] 'callers' not cleaned up correctly ? caused out of memory

[prev] [thread] [next] [Date index for 2004/12/23]

From: Andy Maas
Subject: [Templates] 'callers' not cleaned up correctly ? caused out of memory
Date: 20:25 on 23 Dec 2004
This is a multi-part message in MIME format.
--------------010406010704020604030801
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Our application uses t2  (2.14) and experienced out of memory on large 
iteration. Further look reveal an ever growing 'callers' array.

I wonder if caller removal part of the code might be incorrect. Below is 
code to push and pop from callers array. Is the pop part not using wrong 
object to check (should $element be replaced with $component) ?

Our application use one template that includes other templates. a 
Template object is instantiated once and called 100000 times against 
different data. At about 50000 iteration we would run out of memory.

Andy

            if (UNIVERSAL::isa(*$component*, 'Template::Document')) {
                $element->{ caller } = $component->{ name };
                $element->{ callers } = $component->{ callers } || [];
                push(@{$element->{ callers }}, $element->{ caller });
            }
 
            ....

            pop(@{$element->{ callers }})
                if (UNIVERSAL::isa(*$element*, 'Template::Document'));
                                                                      
^^^^^^^^

--------------010406010704020604030801
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Our application uses t2&nbsp; (2.14) and experienced out of memory on large
iteration. Further look reveal an ever growing 'callers' array.<br>
<br>
I wonder if caller removal part of the code might be incorrect. Below
is code to push and pop from callers array. Is the pop part not using
wrong object to check (should $element be replaced with $component) ?<br>
<br>
Our application use one template that includes other templates. a
Template object is instantiated once and called 100000 times against
different data. At about 50000 iteration we would run out of memory.<br>
<br>
Andy<br>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (UNIVERSAL::isa(<b>$component</b>,
'Template::Document')) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $element-&gt;{ caller } = $component-&gt;{ name };<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $element-&gt;{ callers } = $component-&gt;{ callers }
|| [];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push(@{$element-&gt;{ callers }}, $element-&gt;{ caller
});<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pop(@{$element-&gt;{ callers }})<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (UNIVERSAL::isa(<b>$element</b>,
'Template::Document'));</tt><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
^^^^^^^^<br>
</body>
</html>

--------------010406010704020604030801--

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] 'callers' not cleaned up correctly ? caused out of memory
Andy Maas 20:25 on 23 Dec 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52