PHP7.1 - Fatal Error Unable to allocate shared memory segment - php

I cross-compiled PHP7.1 for ARMv7 and enabled OPCache extension.
In php.ini:
zend_extension=opcache.so
opcache.enable=0
opcache.memory_consumption=4
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=0
On target machine, whenever I try to run a PHP script I get:
Fatal Error Unable to allocate shared memory segment of 8388608 bytes
I made sure that system shared memory allocation is correctly configured:
ipcs -ml:
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 131072
max total shared memory (kbytes) = 131072
min seg size (bytes) = 1
Disabling the OPCache makes the PHP scripts run as it should.
Any idea please?

Related

How can I allowed more memory for laravel

I have just installed Laravel on my web server but after I run the php artisan serve command and navigate to my server's Laravel URL I am getting this error:
[Tue Oct 15 11:38:54 2019] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 77824 bytes) in /Users/apple/eAT/vendor/composer/ClassLoader.php on line 444
You can increase the memory allocation to PHP by editing the memory_limit variable in php.ini file.
Alternatively, you can edit the .htaccess file and add php_value memory_limit 256M to set memory limit for specific application where 256 is the memory allowed to the application. This, however, isn't tested by me.
You may need to restart your PHP server.

php.exe (WAMP) cannot allocate more than 1G memory, even with memory _limit set to -1

Since a few days, I cannot update my Symfony projects using Composer because the php.exe process from my WAMP install cannot allocate more than 1G of memory... I don't recall making any changes in my PHP settings.
In the php.ini (yes, the correct one), I've set memory_limit to -1. My composer diagnose is all set to OK.
My PHP version is 5.6.18
My WAMP version is 3.1.3
My OS is Windows 7
My Composer version is 1.6.5
Could it come from a Windows setting?
Here is the error message I get :
Fatal error: Out of memory (allocated 1397751808) (tried to allocate 268435456 bytes) in phar://C:/wamp/www/DESiwid/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220
Segmentation fault
I have the same kind of error with a PHP test standalone script that I have coded to allocate :
set memory_limit to 810M
memory limit is 810M
try allocating 800 megabyte...pass.Usage: 800.5 Peak: 800.5
memory_limit (get value):849346560
set memory_limit to 860M
memory limit is 860M
try allocating 850 megabyte...pass.Usage: 850.5 Peak: 850.5
memory_limit (get value):901775360
set memory_limit to 910M
memory limit is 910M
try allocating 900 megabyte...pass.Usage: 900.5 Peak: 900.5
memory_limit (get value):954204160
set memory_limit to 960M
memory limit is 960M
try allocating 950 megabyte...
Fatal error: Out of memory (allocated 262144) (tried to allocate 996147201 bytes
) in C:\wamp\www\_test\memory.php on line 5
OK I found a solution : I was using WAMP 32bits, and switched to WAMP 64bits, that solved everything.

php file run as a cron exceeds memory allocation - works fine in browser

I have a php file that I can run fine by visiting the url in a browser but if I try to run it as a cronjob or via PuTTY then I get the following error:
PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 12288 bytes) in /var/www/html/admin/bv_cron.php on line 215
I've updated the following php.ini files:
/etc/php5/apache2 and /etc/php5/cgi
both having set memory_limit to 1024M
There are no htaccess files that alter this and no "local" php.ini files.
Apache has been restarted and the server (ubuntu) has been rebooted.
1024M is far larger than the 262144 bytes so is it not recognising this value? (the server has a max of 3GB of memory).
What could the possible issues be?
--edit--
There was a MySQL query in this file - even when this was removed to test if this was taking up memory it still came out with the error.

Apache 2.4 - mod_fcgid: stderr: PHP Fatal error: Out of memory

Apache 2.4.17 32-bit on Windows 10 x64, FCGI/PHP 7.0.4 32-bit. I am fighting with the error:
mod_fcgid: stderr: PHP Fatal error: Out of memory (allocated 117440512) (tried to allocate 201326600 bytes) in ...
There is many advices but nothing works. Are there more parameters that can affect it? My settings are:
PHP.INI:
memory_limit = 1500M ; confirmed in phpinfo()
HTTPD.CONF:
RLimitMEM 1500000000 1500000000
(RLimitMEM max max # didnt work too)
My physical memory is 12GB and 5.5 GB is permanently free.
I think this error didn't appear in Apache 2.2. I always needed memory limit greather than 500MB. Only one customer needs export to big CSV. The error occurs by concatenating strings. But I am concatenating always only 1 row and immediately writing it using fputcsv() into tempfile. One row reaches maximum 1-2 KB. I don't know about any variable that can grow over many megabytes.
Maybe memory leak or bad garbage collector in PHP 7?

Nginx and PHP FastCGI php-cgi error: Fatal Error Unable to allocate shared memory segment of 67108864 bytes: mmap: Cannot allocate memory (12)

i was trying to set up Nginx with PHP CGI on one of my virtual servers. I tried this by following this tutorial: http://www.farinspace.com/install-and-configure-nginx-server/
Nginx was giving me error 502, so i started examining the error and found php-cgi not starting and just giving the following error:
root#xxxxx:/home/xxxxx# start-stop-daemon --start --chuid "www-data" --exec /usr/bin/env -- - USER=www-data PATH=/usr/bin PHP_FCGI_CHILDREN=1 PHP_FCGI_MAX_REQUESTS=1 /usr/bin/php-cgi -b 127.0.0.1:9000
Sun May 10 03:28:34 2015 (3351): Fatal Error Unable to allocate shared memory segment of 67108864 bytes: mmap: Cannot allocate memory (12)
looking at cat /proc/user_beancounters
Version: 2.5
uid resource held maxheld barrier limit failcnt
78166448: kmemsize 14897923 15745024 33554432 41943040 0
[...]
shmpages 5139 5139 20480 20480 28
[...]
it seems that php-cgi is running agianst some memory limit. since my system is using 200MB of 2,2GB RAM i cannot explain or fix this error. I haven't touched the config php.ini, so afaik this limit should be at about 64 MB RAM.
Any suggestions why php-cgi is not working for me?
Failcnt is more than 0 for shmpages, so it looks like php-cgi is bumping up against that limit.
Contact your hosting provider and ask them to increase the shmpages limit would be your best bet.

Categories