fix memory leak

This commit is contained in:
uwe.tews@googlemail.com
2011-01-14 21:51:08 +00:00
parent d8f8e417f4
commit cfd81bafba
2 changed files with 11 additions and 17 deletions

View File

@@ -275,11 +275,13 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
Smarty_Internal_Debug::end_compile($this); Smarty_Internal_Debug::end_compile($this);
} }
// release objects to free memory // release objects to free memory
foreach (Smarty_Internal_TemplateCompilerBase::$_tag_objects as $i => $d) { Smarty_Internal_TemplateCompilerBase::$_tag_objects = array();
unset(Smarty_Internal_TemplateCompilerBase::$_tag_objects[$i]); $this->compiler_object->parser->root_buffer = null;
} $this->compiler_object->parser->current_buffer = null;
unset ($this->compiler_object->parser->root_buffer,$this->compiler_object->parser->current_buffer,$this->compiler_object->parser, $this->compiler_object->parser = null;
$this->compiler_object->lex,$this->compiler_object->template,$this->compiler_object); $this->compiler_object->lex = null;
$this->compiler_object->template = null;
$this->compiler_object = null;
} }
/** /**

View File

@@ -87,23 +87,15 @@ class Smarty_Internal_Utility {
echo ' is up to date'; echo ' is up to date';
flush(); flush();
} }
// free memory
foreach ($this->smarty->template_objects as $key => $d)
{
unset($this->smarty->template_objects[$key]);
}
$this->smarty->template_objects = array();
foreach ($_tpl->smarty->template_objects as $key => $d)
{
unset($_tpl->smarty->template_objects[$key]);
}
$_tpl->smarty->template_objects = array();
unset($_tpl);
} }
catch (Exception $e) { catch (Exception $e) {
echo 'Error: ', $e->getMessage(), "<br><br>"; echo 'Error: ', $e->getMessage(), "<br><br>";
$_error_count++; $_error_count++;
} }
// free memory
$this->smarty->template_objects = array();
$_tpl->smarty->template_objects = array();
$_tpl = null;
if ($max_errors !== null && $_error_count == $max_errors) { if ($max_errors !== null && $_error_count == $max_errors) {
echo '<br><br>too many errors'; echo '<br><br>too many errors';
exit(); exit();