DOMDocument PHP Memory Leak

后端 未结 4 1964
长情又很酷
长情又很酷 2020-12-03 08:51

Running PHP 5.3.6 under MAMP on MAC, the memory usage increases every x calls (between 3 and 8) until the script dies from memory exhaustion. How do I fix this?



        
4条回答
  •  庸人自扰
    2020-12-03 09:03

    Using libxml_use_internal_errors(true); suppresses error output but builds a continuous log of errors which is appended to on each loop. Either disable the internal logging and suppress PHP warnings, or clear the internal log on each loop iteration like this:

    loadHTML(file_get_contents('ebay.html'));
     unset($dom);
     libxml_use_internal_errors(false);
     libxml_use_internal_errors(true);
     echo memory_get_peak_usage(true) . "\r\n"; flush();
    }
    ?>
    

提交回复
热议问题