PHP: How To Fix Mostly wp-db.php Out Of Memory

Have you run big wordpress site and suddenly find out there is something not working after your wordpress site become bigger? I do, and sometimes I was thinking to use other CMS because there is no better solution for this case. Out of memory problem can only be solved by raising the memory_limit, The problem is how if I’m still using shared hosting?

Actually this case already happen to me long time ago. When my site with worpdress CMS become bigger I notice wp-db.php error in hosting logs. Mostly all errors coming from out of memory. I have not found the real solution for this problem the only way is raising the memory_limit in php.ini file.

Raising memory_limit in php.ini file is not smart solution, Said the standard shared hosting only allowed you to use memory_limit 64MB (some only 32MB) if you change the memory_limit in single php.ini files with new higher memory_limit you hosting provider may suspended your account! Why? because all your php script will run using that single php.ini memory_limit.


Yesterday I was searching on google and found the smart solution for this case. I said smart because we will only allow some php files which may need more memory to run. It will not affect other php files and just run with memory_limit sometimes when you executed it. Your hosting account will be safe and your php script can run as usual without error.

How to do this trick? Just put this small code inside your php files which needed more memory to run.


Put this code inside your php code before php tag closed. Your php files which you added this code will run with memory limit 128MB. You can change 128 value with memory your script may consume example 256. But remember don’t over do it or you may have problem with your hosting provider 😀

This trick can be applied also on other php script with same error message out of memory. Just add that code inside your php files and it will works like a charm.

That’s my share for today, have a nice day everyone 🙂

Similar Posts:


6 thoughts on “PHP: How To Fix Mostly wp-db.php Out Of Memory”

  1. internet credit card processors

    What’s up to every body, it’s my first pay a quick visit of this
    weblog; this blog carries amazing and really excellent information
    for visitors.

  2. I was studying some of your blog posts on this website and I believe this internet site is really instructive! Continue posting.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.