- gc_collect_cycles: documentation ( source)
- xml_parse: documentation ( source)
- memory_get_usage: documentation ( source)
- xml_set_object: documentation ( source)
- xml_parser_free: documentation ( source)
- xml_parser_create: documentation ( source)
<?php
class xml {
var $parser;
function __construct()
{
$this->parser = xml_parser_create();
xml_set_object($this->parser, $this);
}
function parse($data)
{
xml_parse($this->parser, $data);
}
function free(){
xml_parser_free($this->parser);
//unset($this->parser);
}
}
$xml_test = '<?xml version="1.0" encoding="utf-8"?><test></test>';
for ($i = 0; $i < 100; $i++) {
$xml_parser = new xml();
$xml_parser->parse($xml_test);
$xml_parser->free();
unset($xml_parser);
gc_collect_cycles();
echo memory_get_usage(), PHP_EOL;
}