mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
fix memory leak
This commit is contained in:
@@ -275,11 +275,13 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
||||
Smarty_Internal_Debug::end_compile($this);
|
||||
}
|
||||
// release objects to free memory
|
||||
foreach (Smarty_Internal_TemplateCompilerBase::$_tag_objects as $i => $d) {
|
||||
unset(Smarty_Internal_TemplateCompilerBase::$_tag_objects[$i]);
|
||||
}
|
||||
unset ($this->compiler_object->parser->root_buffer,$this->compiler_object->parser->current_buffer,$this->compiler_object->parser,
|
||||
$this->compiler_object->lex,$this->compiler_object->template,$this->compiler_object);
|
||||
Smarty_Internal_TemplateCompilerBase::$_tag_objects = array();
|
||||
$this->compiler_object->parser->root_buffer = null;
|
||||
$this->compiler_object->parser->current_buffer = null;
|
||||
$this->compiler_object->parser = null;
|
||||
$this->compiler_object->lex = null;
|
||||
$this->compiler_object->template = null;
|
||||
$this->compiler_object = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -87,23 +87,15 @@ class Smarty_Internal_Utility {
|
||||
echo ' is up to date';
|
||||
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) {
|
||||
echo 'Error: ', $e->getMessage(), "<br><br>";
|
||||
$_error_count++;
|
||||
}
|
||||
// free memory
|
||||
$this->smarty->template_objects = array();
|
||||
$_tpl->smarty->template_objects = array();
|
||||
$_tpl = null;
|
||||
if ($max_errors !== null && $_error_count == $max_errors) {
|
||||
echo '<br><br>too many errors';
|
||||
exit();
|
||||
|
Reference in New Issue
Block a user