public function memory()
{
$text = 'Много текста';
$baseMemory = memory_get_usage();
gc_enable();
for ($x = 0; $x++ < 10000;) {
$test_model = new Test;
$test_model->create(array('f_1' => $text));
unset($test_model);
if ($x % 500 === 0) {
gc_collect_cycles();
echo $x . "\n";
echo get_file_size(memory_get_usage() - $baseMemory), "\n";
}
}
}
function clear()
{
foreach ($this->nodes as $n) {$n->clear(); $n = null;}
// This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
if (isset($this->root)) {$this->root->clear(); unset($this->root);}
unset($this->doc);
unset($this->noise);
}