PHP Simple HTML Dom Parser Memory Leak / Usage

前端 未结 2 860
情书的邮戳
情书的邮戳 2021-01-01 06:46

I\'m trying to use PHP Simple HTML Dom Parser to parse some information from some sites. Does not matter what and where. But it seems, that there is some HUGE memory problem

2条回答
  •  春和景丽
    2021-01-01 07:45

    I believe you need to call clear() on $main_html

    From the docs...

    Q: This script is leaking memory seriously... After it finished running, it's not cleaning up dom object properly from memory..

    A: Due to PHP5 circular references memory leak, after creating DOM object, you must call $dom->clear() to free memory if call file_get_dom() more than once.

    Example:

    $html = file_get_html(...); 
    // do something... 
    $html->clear(); 
    unset($html);
    

提交回复
热议问题