2

I am using PHP Simple HTML DOM Parser and it is consuming a lot of memory (discovered from using memory_get_usage)! I tried unsetting it but it doesn't do anything.

2 Answers 2

5

See http://simplehtmldom.sourceforge.net/manual_faq.htm

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 then once.

Example:

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

This happens a lot when you are using this library in a loop.

Sign up to request clarification or add additional context in comments.

1 Comment

He should have put this FAQ in BOLD on the Homepage of the library site. That said, it is an awesome and very useful library, and now it can finally run in loop without crashing!
-1

Whatever you want to do with that lib can be made by using The DOMDocument class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.