I've been battling this problem for months now. I have two different systems each with different setups and PHP code but both have exactly the same problem.
My server will throw a 500 error and the logs will be filled with memory allocation issues until a restart of Apache.
System ONE
OS: Windows server 2008
XAMPP: PHP 7.1.9 / Apache 2.4.27
Codebase: A small laravel website nothing fancy
System TWO
OS: Windows server 2016
XAMPP: PHP 7.2.3.0 / Apache 2.4.29
Codebase: Some long running php processes, around 2min.
Apache Errors
VirtualFree() failed: [0x000001e7] Attempt to access invalid address. VirtualAlloc() failed: [0x00000008] Not enough storage is available to process this command. VirtualFree() failed: [0x000001e7] Attempt to access invalid address.
PHP Errors
[Mon May 21 09:27:42.078308 2018] [php7:error] [pid 10236:tid 12736] [client 43.245.8.13:1553] PHP Fatal error: Out of memory (allocated 2097152) (tried to allocate 6626884 bytes) in C:\xampp\htdocs\*\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php on line 141, referer: http://m.facebook.com/
[Mon May 21 09:28:12.703338 2018] [php7:error] [pid 10236:tid 12736] [client 122.170.190.70:63513] PHP Fatal error: Out of memory (allocated 73400320) (tried to allocate 4096 bytes) in C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 294
[Mon May 21 09:28:14.640812 2018] [php7:error] [pid 10236:tid 12736] [client 122.170.190.70:63529] PHP Fatal error: Out of memory (allocated 37748736) (tried to allocate 4096 bytes) in C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 294
[Mon May 21 09:28:19.218972 2018] [php7:error] [pid 10236:tid 12736] [client 157.49.220.122:64984] PHP Fatal error: Out of memory (allocated 20971520) (tried to allocate 4096 bytes) in C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasEvents.php on line 161, referer: https://www.facebook.com/
[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP Fatal error: Out of memory (allocated 12582912) (tried to allocate 131072 bytes) in C:\xampp\htdocs\*\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php on line 141
[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP Fatal error: Out of memory (allocated 12582912) (tried to allocate 32768 bytes) in C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php on line 451
[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP Fatal error: Out of memory (allocated 12582912) (tried to allocate 20480 bytes) in Unknown on line 0
What triggers the errors
The errors seem to occur randomly, but not straight away after an Apache restart. As if its hogging memory, however, I have 6GB of 8GB free on the server.
What I've tried so far
Various php.ini memory tweaks, eg memory_limit=1200M
and also in script tweaks ini_set('memory_limit', -1);
Apache config tweaks
ThreadStackSize 56*1024*1024
ThreadsPerChild 150
MaxConnectionsPerChild 0
RLimitMEM 99999999999 99999999999999
However, I did notice after the restart it says
AH00118: RLimitMEM not supported on this platform
I've seen these errors scattered around the internet and no one ever seems to find a solution for them. I need PHP on Windows, I'm starting to think I should try IIS.
Are there any other recommendations on Apache config or what else I could try?
User contributions licensed under CC BY-SA 3.0