I'm running a php script via terminal and I get this error message Allowed memory size of 536870912 bytes exhausted.
So i then added ini_set("memory_limit", "4096M"); to the php file and that did not work.
Then i run php --ini to see which loaded cli file (/etc/php/7.4/cli/php.ini) is being used and after editing said file i found that there is no memory limit set in it ini_set("memory_limit", "-1");
I have no idea what's going on (not very linux savvy). Where is it drawing the conclusion that it only has 512M of available memory?
Edit #1: I also did a phpinfo() which said the php.ini file is at /etc/php/7.4/apache2/php.ini so I edited that file as well, still getting the same result (restarted apache and initiated a new terminal window as well)
Edit #2: the script is run by php mylocalphpfile.php -params
Ubuntu 20, php 7.4
Ok found out that the forked script from Github has some references to other dependencies in which the memory_limit is being forced to be 512M.
Removed that line of code form the lib and now it's working.
I'm getting the error when trying to access any page running on the builtin php webserver (including just a phpinfo):
Fatal error: Could not delete queued timer in Unknown on line 0
This is the command I am using to run the server
~/php-win$ wine php.exe -S localhost:8080
Here is the content of my php.ini file, which I am assuming is the cause of the error because of the Unknown on line 0 part.
Through trial and error I have discovered that if I comment out the max_input_time value then pages will load fine however the error shows up at the bottom of the page instead. See the below image:
I also had the exact same issue when attempting to set up an EasyPHP server as well (through wine also).
The only other question I could find on this error was this question, however this is happening when I run any file through the built-in webserver, including a blank file.
Also, I am using PHP 7.1.3
Edit your php.ini and put the location of extension folder , the folder named ext inside your php folder
php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "/media/viney/01D58852BCA3B9C0/UwAmp/bin/php/php-7.0.3/ext"
Then I enable a few extensions in php.ini
php.ini
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
Now if I run php, extenions get loaded
viney#Notebook:/media/viney/01D58852BCA3B9C0/UwAmp/bin/php/php-7.0.3$ wine php -S localhost:8080
PHP 7.0.3 Development Server started at Mon May 4 09:28:07 2020
Listening on http://localhost:8080
Document root is Z:\media\viney\01D58852BCA3B9C0\UwAmp\bin\php\php-7.0.3
Press Ctrl-C to quit.
I've installed latest XAMPP server with PHP 7 (update: checked also PHP 7.1) (on my Windows 10 system). Wanted to use opcache, so I enabled it in php.ini.
[opcache]
zend_extension=php_opcache.dll
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
With that change now, and with almost every page refresh, I'm getting this error from Apache:
AH00428: Parent: child process 3748 exited with status 3221226356 -- Restarting.
So, page is loading, and loading... waiting to Apache start again. When I'm turning opcache off (by setting opcache.enable=0), Apache is not restarting and everything works fine (omitting the slower web application topic, of course).
Everything works fine while loading app on XAMPP having PHP 5.6 with enabled opcache.
EDIT (added GIF image):
As you can see, sometimes page refreshes like it should. But sometimes it's refreshing much longer, and Apache is restarting in that moment.
EDIT:
To be honest, I gave up with this application and working with PHP on Windows (was working on it for around 10 years with PHP <= 5.6). It's very hard/impossible (for now) to make PHP 7.x work on that OS (with Opcache). Decided to go with Ubuntu and server created with Docker. Everything is easier to configure (especially with Docker) and works faster. I advise everyone to do the same ;).
Your php_opcache.dll path seems wrong, you need write it like below, it works for me.
[opcache]
zend_extension=C:\xampp\php\ext\php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.max_accelerated_files=2000
More details
If your XAMPP comes with PHP 5.5+ by default, opcache already included in the bundle, you will just need to enable it. To enable the extension:
Open php.ini (by default it should be located here: C:\xampp\php\php.ini).
Add this line at the end of the file:
zend_extension=C:\xampp\php\ext\php_opcache.dll
Restart Apache server.
open a php.ini file
Change the ;opcache.enable=1 to opcache.enable=1
Add opcache dll path at the end of the file zend_extension = "C:\xampp\php\ext\php_opcache.dll"
Restart apache
for more reference check this video https://www.youtube.com/watch?v=GvWrNoRDjUY
In case of Xampp, just put the below lines next to [opcache]
zend_extension="C:\xampp\php\ext\php_opcache.dll"
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
To be honest - do not use xammp. Right now we have a bit better tech stack, to run PHP on Linux servers.
Docker
https://docs.docker.com/docker-for-windows/
Vagrant:
https://www.vagrantup.com/
Both of them are based on linux systems, where most of xammp problems will not have place.
First at all:
This is 2022 and I had a similar problem too with PHP-7.2, not on Xamp, but similar server.
How I've got my problem solved?
If you're here because of that, at first try to go with a default "opcache configuration options". And just above opcache.enable=1 put zend_extension=opcache. Your PHP is smart enough to find the extension. And yeah, there's no need to define the full path if you have defined it here extension_dir = [YOUR PATH] (in php.ini). Of course you can use the full path too, if you want too. The path, probably, it's not a problem if your extension is there (in the folder with all PHP extensions). Did you checked, is it there, your extension?
My problem was in this two options:
opcache.memory_consumption
opcache.interned_strings_buffer
I have no idea why, but I guess this two option should have some balance, because both of them is about memory usage.
So, this had my Apache useless, because it didn't wanted to start
opcache.memory_consumption = 64
opcache.interned_strings_buffer = 32 ;this one BAD
next one works fine!
opcache.memory_consumption = 64
opcache.interned_strings_buffer = 16
this one is works fine too!
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 32
So, as I said, at first try to go with a default values of "opcache configuration options", and later do experiments.
How to check everything works on PHP?
var_dump ( zend_version() );
var_dump ( extension_loaded("opcache") ); // bool(false) cuz it's ZEND
var_dump ( extension_loaded("Zend OPcache") ); // bool(true)
// Next one will give you a lot of data about current opcache usage,
// but of course, only if your extension is enabled.
print_r ( opcache_get_status() );
Default OPcache configuration options you can find here:
https://www.php.net/manual/en/opcache.configuration.php
Creeating directory with appropriate permissions and setting it php.ini worked!
opcache.file_cache=d:\xampp\htdocs\opcache
ThreadStackSize 8388608
Helped me in the similar case. This is a httpd option.
on php.ini add more
zend_extension=opcache
remove comment
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=256
opcache.max_accelerated_files=10000
restart apache
Evening, I am try to run a script that need a lot of memory from the command line.
System is Linux LinuxMint 3.2.0-23-generic w/ PHP Version => 5.3.10-1ubuntu3.6
I have memory_limit -1 in php.ini for CLI and am also setting ini_set( 'memory_limit', '-1' );
but if I run phpinfo() via the command line it says:
memory_limit => 300M => -1
Does anyone have any idea why this is?
I've also tried setting the memory limit via the command on the CLI. No difference.
Thanks for the info, Sammitch, but when I am running scripts I get:
PHP Fatal error: Allowed memory size of 314572800 bytes exhausted (300MB)
It appears this is a system, issue, but I cannot fix it.
EDIT: after searching, I found I had set a memory limit of 300MB in my global config.php file. Be diligent!
You're not understanding the format.
variable_name => default_value => current_value
I recently got stuck on this php error I am receiving :
PHP Warning: PHP Startup: Unable to load dynamic library 'c:\PHP\php_soap.dll' - The specified procedure could not be found. in Unknown on line 0
I have declared the dll in both my ini files. I'm running windows 7 and the site is hosted on iis using a MSSQL Database. I'm using PHP 5.4.1 (Company Policy)
My ini file for the changes :
; Directory in which the loadable extensions (modules) reside.
extension_dir = "c:\PHP"
extension=php_soap.dll
[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled = 0
; Sets the directory name where SOAP extension will put cache files.
soap.wsdl_cache_dir="/tmp"
; (time to live) Sets the number of second while cached file will be used
; instead of original one.
soap.wsdl_cache_ttl=86400
Please help, I've tried everything. Even re-installing.
Thank you.
Are you sure php_soap.dll is in the folder c:\PHP\? If not, you need to adjust the extension_dir config setting in php.ini to the proper extension folder.