• <bdo id='p5ySt'></bdo><ul id='p5ySt'></ul>

  1. <legend id='p5ySt'><style id='p5ySt'><dir id='p5ySt'><q id='p5ySt'></q></dir></style></legend>

  2. <tfoot id='p5ySt'></tfoot>

    <small id='p5ySt'></small><noframes id='p5ySt'>

  3. <i id='p5ySt'><tr id='p5ySt'><dt id='p5ySt'><q id='p5ySt'><span id='p5ySt'><b id='p5ySt'><form id='p5ySt'><ins id='p5ySt'></ins><ul id='p5ySt'></ul><sub id='p5ySt'></sub></form><legend id='p5ySt'></legend><bdo id='p5ySt'><pre id='p5ySt'><center id='p5ySt'></center></pre></bdo></b><th id='p5ySt'></th></span></q></dt></tr></i><div id='p5ySt'><tfoot id='p5ySt'></tfoot><dl id='p5ySt'><fieldset id='p5ySt'></fieldset></dl></div>

      DOMDocument PHP 内存泄漏

      时间:2023-07-16
    1. <small id='EoTJx'></small><noframes id='EoTJx'>

        <bdo id='EoTJx'></bdo><ul id='EoTJx'></ul>
        <i id='EoTJx'><tr id='EoTJx'><dt id='EoTJx'><q id='EoTJx'><span id='EoTJx'><b id='EoTJx'><form id='EoTJx'><ins id='EoTJx'></ins><ul id='EoTJx'></ul><sub id='EoTJx'></sub></form><legend id='EoTJx'></legend><bdo id='EoTJx'><pre id='EoTJx'><center id='EoTJx'></center></pre></bdo></b><th id='EoTJx'></th></span></q></dt></tr></i><div id='EoTJx'><tfoot id='EoTJx'></tfoot><dl id='EoTJx'><fieldset id='EoTJx'></fieldset></dl></div>
                <tbody id='EoTJx'></tbody>

                <legend id='EoTJx'><style id='EoTJx'><dir id='EoTJx'><q id='EoTJx'></q></dir></style></legend>
              1. <tfoot id='EoTJx'></tfoot>
                本文介绍了DOMDocument PHP 内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 MAC 上的 MAMP 下运行 PHP 5.3.6,内存使用量每 x 次调用(3 到 8 次)增加一次,直到脚本因内存耗尽而终止.我该如何解决这个问题?

                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?

                libxml_use_internal_errors(true);
                while(true){
                 $dom = new DOMDocument();
                 $dom->loadHTML(file_get_contents('http://www.ebay.com/'));
                 unset($dom);
                 echo memory_get_peak_usage(true) . '<br>'; flush();
                }
                

                推荐答案

                Using libxml_use_internal_errors(true); 会抑制错误输出,但会构建一个连续的错误日志,并附加到每个循环中.要么禁用内部日志记录并抑制 PHP 警告,要么像这样清除每次循环迭代的内部日志:

                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:

                <?php
                libxml_use_internal_errors(true);
                while(true){
                 $dom = new DOMDocument();
                 $dom->loadHTML(file_get_contents('ebay.html'));
                 unset($dom);
                 libxml_use_internal_errors(false);
                 libxml_use_internal_errors(true);
                 echo memory_get_peak_usage(true) . "
                "; flush();
                }
                ?>
                

                这篇关于DOMDocument PHP 内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:php/symfony/doctrine 内存泄漏? 下一篇:PHP Imagick 内存泄漏

                相关文章

                <tfoot id='LSQnQ'></tfoot>
                1. <legend id='LSQnQ'><style id='LSQnQ'><dir id='LSQnQ'><q id='LSQnQ'></q></dir></style></legend>
                  1. <i id='LSQnQ'><tr id='LSQnQ'><dt id='LSQnQ'><q id='LSQnQ'><span id='LSQnQ'><b id='LSQnQ'><form id='LSQnQ'><ins id='LSQnQ'></ins><ul id='LSQnQ'></ul><sub id='LSQnQ'></sub></form><legend id='LSQnQ'></legend><bdo id='LSQnQ'><pre id='LSQnQ'><center id='LSQnQ'></center></pre></bdo></b><th id='LSQnQ'></th></span></q></dt></tr></i><div id='LSQnQ'><tfoot id='LSQnQ'></tfoot><dl id='LSQnQ'><fieldset id='LSQnQ'></fieldset></dl></div>
                    • <bdo id='LSQnQ'></bdo><ul id='LSQnQ'></ul>

                    <small id='LSQnQ'></small><noframes id='LSQnQ'>