20.7 Saving Memory


You don't want to leave inactive parsers lying around. What does the XML API offer in terms of managing your parsers?

Technique

Use the xml_parser_free() function, which will free up a parser. This is not needed in PHP 4 because it has support for basic garbage collection, but you should use this with PHP 3:

 <?php     $parser = xml_parser_create();     // Do your thing     xml_parser_free ($parser); ?> 

Comments

The xml_parser_free() function will free an already allocated parser. Although this is done for you in PHP 4 because of reference counting, your scripts will leak in PHP 3 if you do not call this function.



PHP Developer's Cookbook
PHP Developers Cookbook (2nd Edition)
ISBN: 0672323257
EAN: 2147483647
Year: 2000
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net