PHP Error - keep getting "Out of memory error" - php

I kept getting this error on one of the site Im working on
Message Out of memory (allocated 2097152) (tried to allocate 20480 bytes)
and the thing is we already set the memory limit to 512MB, and seems weird that it says allocated 2097152 which is like only 2MB?
This site is running in wordpress with woocommerce, and the even woocommerce status says the memory limit is 512MB.
Can anybody explain whats going on?
Server is running on NGINX + PHP-FPM

Try set upload_max_filesize, post_max_size , max_file_uploads and memory_limit in php.ini and then restart your Apache server. If it did not work, try to set the mentioned parameters to right on top of your code.
Best way to increase memory limit in PHP or WordPress.
Via php.ini file
memory_limit 2048M
post_max_size 200M
upload_max_filesize 20M
max_file_uploads 20
Via PHP script
ini_set('memory_limit','2048M');
ini_set('post_max_size','200M');
ini_set('upload_max_filesize','20M');
ini_set('max_file_uploads','20');
Via wp_config.php file in WordPress
define('WP_MEMORY_LIMIT', '2048M');
Via htaccess
php_value memory_limit 256M
php_value post_max_size 200M
php_value upload_max_filesize 20M
php_value max_file_uploads 20

In wp-config file Update the memory limit according to your need
define('WP_MEMORY_LIMIT', '256m');
define('WP_MAX_MEMORY_LIMIT', '512m');

Related

connection reset when upload file with size more than 1GB

I try to upload file to my own website when I try upload file with less than 1GB it's work fine, But when I try with large file give me message : "The connection was reset." ERR_CONNECTION_RESET
Then I try to edit and increase all value php.ini
php_value max_execution_time 10000
php_value max_input_time 10000
php_value max_input_vars 1000
php_value memory_limit 2000M
php_value post_max_size 2000M
php_value session.gc_maxlifetime 10000
php_value upload_max_filesize 2000M
In the end still have a problem
I work on my own server and I have access to whm, cpanel with centos 7
And there's no logs for this problem on apache logs
Can you check the features of the package you added on WHM? The quota of the package you have added may be low.

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes)

I am having this common php error: ‘Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in C:\laragon\www\testone\wp-includes\class-wp-hook.php on line 312’
I increased the memory limit in the wp-config:
define( 'WP_MEMORY_LIMIT', '256M' );
define('WP_MAX_MEMORY_LIMIT', '256M');
in the .htaccess
php_value memory_limit 256M
php_value upload_max_filesize 12M
php_value post_max_size 13M
and created a php.ini file in the wp-content/plugins files (the php.ini didn’t exist after downloading laragon)
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
upload_max_filesize = 12M
post_max_size = 13M
I also created a info.php file and it says that the max memory limit is 256M Nothing works ANy help would be greatly appreciated, thanks!
So using Laragon and citing this link https://forum.laragon.org/topic/610/laragon-3-1-4-released-supports-php-7-2
It looks like you can edit the php.ini config through the Laragon menu. Once you've made your changes I suggest restarting Laragon and seeing if the changes you've made have taken effect.

How to fix connection was reset error in laravel 6

I use Laravel 6.2. I try to upload a video. The size is ~700mb, but when I submit the form I receive the following error in Chrome:
The connection was reset
I tried to upload a video which has ~5mb size and it worked fine.
I disabled XCache, but it did not work.
P.s: Post_max_size and upload file size is 2gb
Try the following:
Apache: Edit your httpd.conf file, and increase max_execution_time as well as max_input_time:
<Directory "[path/to/this/directory]">
php_value upload_max_filesize 2000M
php_value post_max_size 2000M
php_value max_execution_time 600
php_value max_input_time 600
</Directory>
PHP: you can also increase time and size in your php.ini file:
post_max_size = 2G
memory_limit = 512M
max_execution_time = 36000
max_input_time = 60
Then, restart your Apache server and try again.

PHP Warning: POST Content-Length of 66192047 bytes exceeds the limit of 8388608 bytes

im getting this error when sending a form with uploaded file.
i already put upload_max_filesize and post_max_size to 1000M in my php.ini without any result.
If you did setting php.ini file and then restart Apache daemon or Server.
Please check your php source files and .htaccess file.
First.
Maybe contain ini_set('upload_max_filesize', '8M') or
ini_set('post_max_size', '8M').
They can be in index.php file.
Second.
They can be in .htaccessfile.
php_value upload_max_filesize 10M
php_value post_max_size 10M

What's limiting my PHP resources?

I'm having a problem getting more memory out of PHP.
This is the error message:
Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 82 bytes) in ...
Yet:
I've set memory_limit in the php.ini file to 32M:
memory_limit = 32M;
I've also tried to override it manually in the actual script:
ini_set('memory_limit', '32M');
And -- here's where I'm lost -- I've confirmed via phpinfo() that this php.ini file is the actual ini file used, and the memory_limit seems to be set correctly. The line on memory_limit gives this:
memory_limit 32M 32M
So it would seem that everything is configured properly, but I'm only getting 20971520 bytes (~20M).
Where else should I be looking to figure out where this limitation is being imposed?
EDIT: I'm running php under nginx/fastcgi, on Ubuntu 9.04 in a VPS. The php-cgi processes do seem to be a bit resource-hungry (RES=25m, VIRT=187m), but I have 10m of physical memory free and 500m of swap space free.
My first instinct is to guess that PHP is reading a different php.ini.
In Debian (and most likely Ubuntu), each version of PHP (cli, cgi, and apache) has its own copy of php.ini.
I just pored over the code I was running, and someone had hard-coded this into a config file:
ini_set('memory_limit', '20M');
Which was overriding everything else I was doing. Whew.
You could try setting it in the .htaccess file, that is what i had to do to get a site working on one server.
here are the settings i used:
php_value upload_max_filesize 50M
php_value post_max_size 60M
php_value memory_limit 128M

Categories