I've noticed a strange behaviour in XAMPP v3.3.2
with the PHP
memory limit settings. My computer has Windows 10
installed and I have 8GB of memory
. In my php.ini
file the memory limit is set to 1024M
. I also made this basic php file for testing:
<?php
echo ini_get('memory_limit');
exit;
?>
Running this file with different command line parameters, these are the outputs that I am getting:
php -d memory_limit=512M test.php
outputs 512M
php -d memory_limit=2048M test.php
outputs 2048M
php -d memory_limit=4096M test.php
outputs the following error message:
PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 341351 bytes) in Unknown on line 0
Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 341351 bytes) in Unknown on line 0
php -d memory_limit=5000M test.php
outputs 5000M but I still believe that it is not using 5000M of memory (runned some extended tests populating arrays with numbers, and both the test with 2048M
set and with 5000M
set exits at the same number, with the same message:
PHP Fatal error: Out of memory (allocated 1457258496) (tried to allocate 134217728 bytes) in C:\xampp\htdocs\test\extended_test.php on line 733
Fatal error: Out of memory (allocated 1457258496) (tried to allocate 134217728 bytes) in C:\xampp\htdocs\test\extended_test.php on line 733
I've stumbled upon this when trying to allocate more memory to a script that should run on my computer. Any ideas what could be causing this?