PHP script using too much memory
-
I am having an issue with a script using too much memory.
The message showing is – Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 528384 bytes) in /home/u234536193/domains/monetizingonline.com/public_html/wp-includes/wp-db.php on line 2024
The code on line 2024 is – $this->result = mysqli_query( $this->dbh, $query );
Any ideas or suggestions how to resolve the issue are greatly appreciated!
- This topic was modified 4 years, 3 months ago by Yui. Reason: moved to fixing wordpress
-
this script allocated memory for database query results.
512 Kb, if exactly.
Perhaps your site is already using most of allowed 256Mb of memory_limit.Please see this article about increasing memory limit above 256M
Or you can ask your webhosting support.Thank you for the suggestion!
I have increase the memory limit to 512mb as a temporary fix, however it seems a bit excessive considering the size of the website (only has 5 web pages).
Any idea how to identify what is using so much memory so I can resolve the issue?
You can obtain some data by using https://wordpress.org/plugins/query-monitor/
(disable, dont keep it running on production site permanently)Your theme, heavy plugins can use most of PHP memory, but i expect your host is not well configured, using PHP CLI or PHP-CGI SAPI are known to consume much more memory than PHP-FPM or apache mod_php, OpCode caching (OpCache) can significantly reduce amounts of used memory.
For database queries – using mysqlnd over libmysqlclient (all modern PHP versions usually have mysqlnd). Try asking your webhosting support about server configuration.I took a quick look at the site URL mentioned in the error above…
It says your site is blacklisted with malware… did you know that?
It’s possible the malware is clobbering your memory allocation.
If I’m right about the domain name then you might want to fix the site by scrubbing out all the malware.
Thank you very much!
Is it normal for a small website consisting of 5 web pages (the biggest is a 15,000 words blog post with 4-5 images – optimized) to use more than 256mb of memory. Sorry about the question, I am fairly new to wordpress.
how did you find out that my site is blacklisted with malware? How can I establish if that is the case, please?
normal for a small website consisting of 5 web pages (the biggest is a 15,000 words blog post with 4-5 images – optimized) to use more than 256mb
No, a WooCommerce shop set up with 15000 products can use about 256Mb PHP memory.
Simple site with few pages and several posts shouldnt use more than ~ 64 Mb
Results can vary dependent on server software and configuration
I just checked it through here as I had that Sucuri link up anyway!
https://sitecheck.sucuri.net/results/https/monetizingonline.com
- This reply was modified 4 years, 3 months ago by JNashHawkins.
I found it too, the website is only blacklisted by McAfee and I have contacted them to get it rectified. The blacklisting has nothing to do with malware however. I assume the fact the site is blacklisted by McAfee has no effect on the excessive memory usage? It comes from somewhere else.
- This reply was modified 4 years, 3 months ago by von44.
Late last night I pointed my little web crawler at your site.
There are several redirects probably due to building internal links and then setting permalinks after that.
There’s also a lot of 404 errors… that kind of stuff takes some horsepower to deal with.
If it was my site I’d double-check the links… get rid of the ones that don’t use the permalinks in favor of the proper permalinks. Menus are a very good place to look but some of the ‘read more’ links on your blog items (the loop pages) are broken.
As to the site itself security wise, I still suspect you might have some issues there.
Why not install IthemesSecurity and WordFence together and let them help keep an eye on attack items and security. IthemesSecurity and Wordfence play well together and complement each other.
I’d also install the Sucuri plugin and run it for a little while just to see if it finds anything. Then disable it but I always leave it installed in case I need to double-check things again.
I’d also recommend running the Broken Link checker plugin… That might help you get a grip on the 404 errors and keep things inline if you’ll pay attention to it. After a few days, you can throttle that back from its default 72 hours to 480 hrs. That thing can be quite a resource hog at times but 480hrs seems to work fine for me.
Normally, I’d recommend running CloudFlare but your site has response issues. Cloudflare tends to amplify those.
I also took a look at your DNS records. I don’t see a Cname record but the DNS test I then ran said you have one. Your host may have munged their DNS servers to do that but I was also wondering if your htaccess might be ‘belching’ out ‘www’ and then forcing WordPress to deal with that. I can’t tell from here but you might look for that or your site settings in the dashboard being set to ‘www’.
One more thing that might help would be to add a plugin such as Cache Enabler just to have something that works well to handle cache flushing.
It’s also possible that your site doesn’t get enough traffic to run the WordPress pseudo-cron… I usually run an external cron to force WordPress to better keep up with cron tasks.
Finally, if you continue having issues with this server, you might just engage a new server from your same host and migrate everything to there then cancel the old server.
I say do that on your own initiative as your host will probably balk at the idea or break that somehow to lessen the effect. Doing it on your own forces a random selection of new server and forces the complete migration where the host might otherwise leave things as they are and just move pointers and such to humor you.
Not that I’m accusing your host of doing that but ‘it’s so easy to do that kind of stuff’. I usually move servers within the same host after three years on shared hosts. On the Cloud hosts I haven’t seen the need…
I certainly hope something here might help you get to the bottom of all this.
Once you get the problem solved I’d recommend going to Cloudflare.
- This reply was modified 4 years, 3 months ago by JNashHawkins.
Thank you for the thorough explanation. However I checked google search console and google analytics and there is only 1 redirect and no 404 errors. This seems very bizarre.
The broken link checker plugin detected only one 404 error, again I am very confused as to why you data is very different.
The read more pages were not broken, they were just not linked to anything. The site is still the the initial stages of being built.
Can you please help with more details info on how to locate and resolve the redirect issues and the 404 errors please?
Is it possible that the blog post that experiences the issue is simply too large. It has around 15000 words, few pictures and a lot of links to external websites? Now I cannot even access the blog post it returns a 503 error. That has been the case for weeks now.
503
Service Unavailable
The server is temporarily busy, try again later!Thank you in advance!
I’m overwhelmed with 404s on your site and I think I’ve tracked that down to an issue with your Google Analytics plugin and the code it’s jamming into your pages.
If you’ll shut down that plugin I’ll run this thing again and see if I can figure out the redirect, if it is still there afterwards, and any 404s outside of that missing GA script code.
Then we’ll take a look at that GA plugin again.
I use Monster Insights to connect wordpress to GA.
Should I deactivate the MI plugin?
Also when I run the broken link checker it only returns one 404 error. How is it that you are getting several 404 errors?
I’m running something that crawl’s your website like a search engine would. The broken Link Checker just looks at the links as it goes along on a shorter timetable but isn’t seeing that broken relative link (and that might be an issue in my crawler).
Did you throttle back the Broken Link Checker? I always recommend running that at 480 hours instead of its default 72 hour setting… once it has ran one time setting it to 480 hrs saves some horsepower and it seems to be able to keep up with everything just fine.
- The topic ‘PHP script using too much memory’ is closed to new replies.