Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress Apache VirtualAlloc and VirtualFree failed, PHP out of memory

I am trying to host a few webpages by myself using Uniform Server WAMP package (Apache version 2.4.20, PHP version 7.0.8), one of them is a simple Bootsrap portfolio and another is a WordPress based online shop using WooCommerce and other plugins.

From time to time my WordPress based site stops working until I restart Apache service. I find main Apache log filled with these errors:

VirtualAlloc() failed: [0x00000008] Not enough storage is available to process this command. VirtualFree() failed: [0x000001e7] Attempt to access invalid address.

And my shops Apache error log full of these:

[Tue Aug 23 14:49:59.357235 2016] [:error] [pid 11300:tid 1768] [client 88.119.96.56:52269] PHP Fatal error: Out of memory (allocated 2097152) (tried to allocate 4096 bytes) in D:\Software\UniServerZ\vhosts\***\wp-includes\pomo\mo.php on line 276, referer: http://***/wp-admin/edit.php?post_type=shop_order

lines differ to 268, 270 and 276, and in mo.php they look like this:

$entry = new Translation_Entry(); // 268
...
$parts = explode(chr(4), $original); // 270
...
$parts = explode(chr(0), $original); // 276

Whole source code can be found here.

In the meantime my portfolio page works without issues.

I increased memory_limit in php.ini to 2048MB, added define('WP_MEMORY_LIMIT', '256M'); and define('WP_MAX_MEMORY_LIMIT', '512M'); to wp-config.php, but still at least two times a week my website is not accessible and logs full of messages mentioned above.

My sites do not generate much traffic, server has 16GB of RAM and half-empty 512GB SSD, please help me understand or find out what is causing the issue because current logs say very little to me.

Update 1

I found an interesting line above all those VirtualAlloc and VirtualFree fails:

[Tue Aug 23 21:02:40.298272 2016] [:error] [pid 504:tid 1836] [client 191.96.249.54:36032] script 'D:/Software/UniServerZ/www/xmlrpc.php' not found or unable to stat

Looks like I was a victim of hacking attempt, disabled xmlprc by adding these lines to .htaccess file:

<Files "xmlrpc.php">
Order Allow,Deny
Deny from all
</Files>

Hope this helps.

Update 2 - a few days later

Looks like issue is resolved, from time to time I find client denied by server configuration errors, but website no longer fails.

Update 3 - a few weeks later

VirtualAlloc() and VirtualFree() fails are back, without any suspicious script requests, log is just full of mentioned fails and my shops log has bunch of mentioned out of memory errors. Is it possible to some how make Apache errors more verbose/detailed to figure out what command triggers the not enough storage error, or what invalid address was attempted to access?

Update 4 - a few months later

After some time of regular website usage and restarting the Apache from time to time the errors just stopped, I suspect some of used plugins has been updated and now memory doesn't leak and everything works until next error...

like image 579
Valdas Avatar asked Aug 23 '16 13:08

Valdas


1 Answers

Not sure this is can help as WordPress does not use PHP native sessions, but can be, that some plugins are using.

My situation: Windows OS, PHP 7.0.6 - 7.0.11
VirtuaAlloc fails due the php session usage. http://php.net/manual/en/features.sessions.php I've removed/replaced all php session_ functions with mine own.

Howto reproduce: session_start(); do parse some huge xml (150MB or more) file do run multiple times same script at the same time on the Apache server.

like image 75
Slider Avatar answered Oct 25 '22 23:10

Slider