Increase PHP performance PHP INI - php

The server is hosted by JustHost and on there are a few separate domains. I am uploading files to wordpress blog on one of the domains and my import only gets through 1332 records each time.
I think this is because there is not sufficient amount of data allowed to upload. I have changed the PHP.ini and it is now really fast, but still same number of records are uploading.
I have put a PHP ini in the public HTML folder and also one in the site route domain folder but am still getting the same results.
post_max_size = 500M
upload_max_filesize = 400M
max_execution_time = 3000
max_input_time = 6000
memory_limit = 2200M
I have also put this line in the wordpress config file
define('WP_MEMORY_LIMIT', '2200M');
Any suggestions?
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 44 bytes) in /home/divethe1/public_html/callinggrove.co.uk/wp-includes/kses.php on line 991

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to
allocate 44 bytes) in
/home/divethe1/public_html/callinggrove.co.uk/wp-includes/kses.php on
line 991
This kind of error is caused by a memory leak in your code its not related to your server config, your building a string or storing a value that is exponentially being assigned growing by its own value on each iteration.
<?php //$str is added to $str
$str = str_repeat('abc',1000);
for($i=0;$i<=100;$i++){
$str = $str.$str;
}?>
or in your case your perhaps building an array of the posts you have added with the entire content added to a value and its running out of memory.
Plz post some of your code around where the error occurs.

If possible try to use a persistent connection.
I don't know if you can do that using wordpress.

Related

WooCommerce and Wordpress PHP memory_limit problem

I have three WooCommerce based shops installed on my server, basically they are identical shops using the same plugins and themes and the assortment is almost identical (product presentation also).
Each store database has less than 100MB.
In one case I have memory problem for PHP scripts, while memory_limit is set to 256M one store still has memory problems. Others work ok.
[01-May-2020 22:23:08 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 14069080 bytes) in /home/shop1/public_html/wp-includes/wp-db.php on line 2951
[01-May-2020 22:33:22 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 10489856 bytes) in /home/shop1/public_html/wp-includes/functions.php on line 708
I can raise the memory_limit to e.g. 384M and the problem disappears. But why does such a script require more than 256MB and the other two do not? Is it normal?
You might have a memory leak or from what I can understand if you have set 256M and each one is 100MB that means you only have space for 2 of them and hence the 3rd one is running out of ram.
Make sure that on your php.ini you put more ram and then assign enough ram to each webstore that does not surpass your overall amount.
Your php.ini is most likely taking over and setting the overall RAM rather than the ram PER instance. Hope that makes sense.

PHP out of memory though I have MUCH MUCH more allocated

I am getting the following error on my Drupal site:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 205668 bytes).
To be sure, 268,435,456 + 205,668 = 268,641,124 bytes = 256.2 MB.
In my php.ini I have memory_limit = 2G. I have verified that I am editing the correct php.ini file. When I xdebug the site and enter ini_get('memory_limit'); into the console, I receive 2G for the output. So I know my file is being read correctly.
I've also checked my .htaccess file to verify that there are no other memory directives in there. There are not. Where is this limit coming from?
It turns out that this site has Drupal's path_memory module enabled, and the path I was trying to hit was configured to have a maximum of 256M available at admin/config/system/path-memory. Tricky.
1) You sir must have a ton of memory to apply 2 gigs for EACH HTTP/PHP process.
2) php memory_limit does not accept 'G' as a proper setting, make it 2048M instead
How to increase memory limit for PHP over 2GB?

Wordpress Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes) in /wp-includes/meta.php on line 837

I am new in wordpress. i am getting below error.
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried
to allocate 72 bytes) in
/wp-includes/meta.php on line 837
while accessing new post page. and also i have added below code in htaccess file.
<IfModule mod_php5.c>
php_value memory_limit 512M
</IfModule>
Please help me to sort out this issue.
Try adding this line to your wp-config.php file:
define('WP_MEMORY_LIMIT', '64M');
If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 32M try 64M:
memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)
If you don't have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 64M
Talk to your host.
In my case deleting old wordpress post revisions helped. Also you can restrict the amount of revision per article or disable it altogether.
Here's how I did it: Limit or Disable and clean up old wordPress revisions
Debug your WordPress installation with these Basic WordPress Debugging Techniques.
I found many WordPress themes showing this error due to a wildcard searching all through the database. If possible, control the query's posts_per_page from -1 to something reasonable.
And the increment in Memory Limit is sometime a temporary solution if your code is buggy, or giving enormous load to your system that your system is not prepare in handling.
Changing the memory limit is usually only masking the real problem, unless you have it set to some really low value. The problem itself is usually hard to pinpoint.
In my case the problem was caused by someone that set the number of posts per page to some absurdly high value like 999 in my case:
When I found it the solution was easy - I just decreased it to something reasonable like 100.

Getting memory use fatal error

My joomla website was working fine and now is giving this error:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes) in ...public_html/libraries/vendor/joomla/string/src/phputf8/substr_replace.php on line 20.
I know the obvious answer is to upgrade the php.ini memory to 512M but my hosting doesn't allow it. First it was here and now
Is there other way to solve it?
In case you don't have access to php.ini, Just create a .htaccess file in your joomla website root folder and add this line to it:
php_value memory_limit 512M

Fatal error: Allowed Memory size of 67108864 in opencart

I'm using opencart. In my admin page when I access CATALOG>PRODUCTS (I have 73 products - Totally I have four pages). When I access my second page it shows this following error
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4000 bytes) in /home/justborn/public_html/system/library/image.php on line 34
But, I can access first, third and fourth page. I have tried this solution (Allowed memory size of 67108864 bytes exhausted (tried to allocate 4459414 bytes) in writing an xml file) in my .htaccess file
php_value memory_limit 128M
But, it returns 500 Internal error.. How do I solve this Fatal error: Allowed Memory size of 67108864 ?
I have found the Solution
In my admin folder I have a php.ini file
I have changed my memory_limit = 64M; to memory_limit = 128M;. Now it works fine.. I didn't get Fatal Error.
Check your images size in filemanager: there might be some big sized images.
I had 2.9MB size of picture which created such trouble to me.
Now, after reducing the size I've solved it.
Memory limit is more than enough.
It seems that there is some endless loop in the script that is not letting it to terminate.
Look for any for, while, do while loop in the script.
If above remedy does not works, please share code so that issue can be examined further.
you have to change the php.ini file on line 18 memory_limit = 64M; to 64 x 2 = 124 or 64 x 4 = 256 but wait ask your hosting provider does they support higher limit size if yes then it will work otherwise you are wasting your energy
This is the same problem I faced,
"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 8192 bytes) in opencart system/library/image.php on line 26"
This error appears when we upload large images (1.5 MB+ size), at the time of editing the images Opencart system/library/image.php tries to load those images and in order to load BIG images it needs more memory.
In order solve this there are two ways.
1. For shared hosting users
1.1 Open File Manager from cPanel or FTP to your website
1.2 Go to "public_html/image/catalog"
1.3 Look for Big Images and Download and delete those images from the server.
VPS - Dedicated - Cloud - Server where we can manage php.ini
2.1 In admin folder open php.ini file
2.2 Try to increase from memory_limit = 64M; to memory_limit = 128M; or more as required.
This should solve the problem.
I would personally advice to upload optimized images and use solution 1 that is deleting Big Images, this is not create any load on the server.

Categories