joblafors Posted October 27, 2009 Share Posted October 27, 2009 Hello. I`m writing web crawler script for one specific site, and i`m using simple_html_dom to find links and specific information in site. But I stumbled on PHP memory problem Fatal error: Allowed memory size of 10485760 bytes exhausted (tried to allocate 16 bytes) in *****\simple_html_dom.php on line 924 . I changed memory limit to 30MB, 50MB .. but this doesn't resolve the problem because eventually memory will be full, that is if script crawls few pages deeper in site. Are there any suggestions how to manage memory in PHP, or are there some better html dom scripts to use (with swap files or smth like that) Thank you !! Quote Link to comment https://forums.phpfreaks.com/topic/179189-php-allowed-memory-size-problem/ Share on other sites More sharing options...
Daniel0 Posted October 27, 2009 Share Posted October 27, 2009 Why it does that depends on how you've written your code. Maybe you don't clean up unused resources. That's simple to fix. Just do manual garbage collection. Maybe you wrote your script recursively and the call stack keeps growing. In that case, you could refactor it to be tail recursive. Maybe you're just trying to keep all the generated data in memory. In that case, write it to permanent storage more frequently. Quote Link to comment https://forums.phpfreaks.com/topic/179189-php-allowed-memory-size-problem/#findComment-945464 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.