Memory problem in PHP simple HTML DOM

I was using PHP Simple HTML dom, a great and free library for parsing html pages and retreiving info from it. I really liked it.. But when it comes to parsing many differents pages of some website in one php script, you will get an error:

Allowed memory size of 67108864 bytes exhausted,

and this is because simple HTML dom don't free up the memory in real time, so the solution is:

Each time you create a dom object ( foe exemple using: $html = file_get_html("http://someurl/"); or  str_get_html... ), then when you don't need it anymore you have to call _destruct:
$html->_destruct();
unset($html);

14 comments:

Anonymous said...

thanks so much for posting this!
but there is a type. it should be __destruct, not _destruct.

Wojtek said...

Thanks a lot!
I was looking for a solution to this problem and that was it.
Would be good to fix the typo, though. Like the guy above wrote, there's a double _

Cheers.

Facebook App Developer said...

yes,
i also was surfing the net for this problem like Wojtek,
and now i have solve my prob,
thanks

Anonymous said...

Thank you very much!

TechToyz said...

Again an awesome Article

rize wordpress said...

Our company has cumulative decades of experience programming PHP in all sorts of applications. PHP Programmers

Lia said...

Thanks for sharing this information and I know it can helpful. I will save it so that if I can encounter a problem in PHP I can use it. Keep it up.

Fully Help said...

Nice blog...Very useful information is providing by ur blog. Great beginning php tutorials Very clear and helpful for beginners.

Giri Mani 2 said...

This blog is having the general information. Got a creative work and this is very different one. We have to develop our creativity mind. This blog helps for this.
Thank you for this blog. this is very interesting and useful.
Digital Marketing Company in Chennai

Sowmiya said...

Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

Best Android Training Institute in Chennai

Samsunda cilingir said...

Selam yonetici admin siteniz cok guzel basarilarinizin devamini bekleriz

Shalini said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.

seo company in india

jeslin said...

Actually social media is the powerful tool to make our project to be visible worldwide. Here this type of article will enable us to know the tricks and tips within the marketing. So please keep update like this.

Back to Original

Prasanth said...

A very well-written post. I read and liked the post and have also bookmarked you. All the best for future endeavors. Getting some solution regarding.
UI Designing Company in Bangalore, Web Application Development Companies in Bangalore