Jump to content

Recommended Posts

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 !!

Link to comment
https://forums.phpfreaks.com/topic/179189-php-allowed-memory-size-problem/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.