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);
2 comments:
-
Anonymous said...
-
thanks so much for posting this!
but there is a type. it should be __destruct, not _destruct. -
March 15, 2011 12:46 AM
-
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. -
April 13, 2011 4:28 AM
Subscribe to:
Post Comments (Atom)
Categories
- 1-General (3)
- 2-Getting started (4)
- 3-Strings (10)
- 4-Server config (1)
- 5-Best scripts (7)
- email (4)
- files (6)
- Forms (3)
- If statements (3)
- Loop statements (2)
- Mysql (2)
- Server variables (3)
- Sessions (1)
- Tutorials-planet.com (1)
- web hosting (1)
- You need a programmer ? (1)
Links to visit !
Blog Archive
-
▼
2010
(12)
-
►
January
(10)
- String Capitalization Functions: strtoupper-strtol...
- PHP For Loop
- PHP Validate Email Address: Email Validator
- PHP Random code Generator
- PHP Get browser Language
- PHP $_REQUEST
- PHP send mail SMTP authentification
- ob_start - save php output to a string - The PHP o...
- PHP send HTML email, The complete php mail sending...
- PHP mail() - send email with php
-
►
January
(10)
-
►
2008
(26)
-
►
August
(22)
- PHP if -- else statement in conditions
- PHP simple if statement
- PHP strpos a searching function
- Run php script in html pages
- PHP Force Download
- PHP Get current file name and url
- HTTP_REFERER: Find the referrer page with php
- PHP Sessions
- PHP Trim()- String functions
- PHP file upload script
- PHP fget: read a file line by line
- PHP String explode
- PHP str_replace and str_ireplace
- PHP Strings
- PHP Operators
- PHP Echo, the relation between php and html
- PHP Variables
- PHP Syntax
- PHP Script installation, PHP and HTML
- PHP Introduction
- PHP files, how to read and write to files ?
- learn every thing about the GREAT PHP
-
►
August
(22)





