error:
Fatal error: Out of memory (allocated 123469824) (tried to allocate 71
bytes) in
/home/test/tset/tset.net/public_html/test/simple_html_dom.php on line
1236
Yes, I know that many of these issues were. But I did not realize how easy it is to avoid this mistake. I need if this error occurs, simply start the loop from the next value.
I use simplehtmldom
code:
$html = file_get_html('http://www.windowsaffinity.com/?p=14721');
EDIT:
YES *maximum memory size is insufficient*
You can't catch fatal errors in PHP. They are, after all, fatal.
Without knowing exactly what you're trying to do, would it be possible to store some kind of counter or other position parameter in a database or other file to "hold your place" until you can restart the script.
If you're running out of memory, you have bigger issues. Either your hosting is much too tiny for what you're trying to do, or you're biting off more than you can chew (or both). Try breaking your process into multiple pieces, and call unset()
and/or assign null
to variables when you're done with them to limit the space you're using, and to tell the garbage collector that your objects are eligible to be collected.
You can raise php's memory limit, via ini_set
, but this should only be done on a per-script bases (eg, importing data from a very large xml/etc file). Excellent question that addresses raising memory limit - Increasing PHP memory_limit. At what point does it become insane? .
Edit: Read update post, in your case I'd raise the memory limit - assuming your writing a quick script for one time use. If ini_set
is disabled (ie, most likely if your on a shared host), set memory_limit in php.ini.
Another option would be to use sockets to fetch the page (read data in small chunks, and save to file or w/e) or run a system command (eg, wget -O /save/here.txt http://blah.com
)