Tutorial - Windows Memory Leak / Apache Restart / status 255

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Tutorial - Windows Memory Leak / Apache Restart / status 255

Postby starams5 » 08. August 2014 04:51


This is my 2nd post on the site although I've been been an xampp user for 3 years now. I would like to share something with the Windows users who chose to use xampp in a production environment.

Try these suggestions at your own risk, and don't hold me or the xampp staff responsible if something goes wrong. Test extensively on your localhost before going live.

My problem has always been an unstable opcode cache (Parent: child process exited with status 255 -- Restarting), and the other one (Parent: child process exited with status 3221225477 -- Restarting). I've been battling this for 3 three years now.

Windows Server 2008 r2
Duel quad xeons
16 gb memory

I don't believe there is one fix, but I did manage to get the server stable with many fixes, and I'll share those. For low traffic sites, mod_fastcgi or mod_fcgid is an option, this post is for site with 400+ online users. mod_fastcgi was slow, to many executables sucking up memory and cpu.

I heard about httpd-2.4.10-win32-VC11 and php-5.5.15-Win32-VC11-x86 resolving some of the memory leaks so I did some testing on the localhost. I backed up the entire Apache "conf" directory, and overwrote the files with httpd-2.4.10-win32-VC11. Then copied the entire "conf" directory back into the Apache folder.

Apache started right up and remained stable. I did the same thing with PHP, please understand, I was desperate for a fix. I repeated the process with php-5.5.15-Win32-VC11-x86, and again things were stable.

xampp was not designed for this purpose. When you visit their, all over, you see xampp was not designed for production. Well, if you examine httpd.conf, and php.ini, and compare it to the standalone installs, you see they mean exactly what they're saying.

I'll start with php, and the setting I altered in php.ini. Read the info on all directives if you are unsure.

Code: Select all
open_basedir = Off
display_errors = Off
display_startup_errors = Off
track_errors = Off
post_max_size = 0 (adjust to suit your needs)
upload_max_filesize = 500M (adjust to suit your needs)
date.timezone = America/Los_Angeles (optional)
mysql.connect_timeout = 60
mysqli.reconnect = On
session.use_only_cookies = 1
session.bug_compat_42 = Off
session.bug_compat_warn = Off
mssql.compatibility_mode = Off ("compatibility" misspelled in xampp php.ini, correct spelling)

I personally use xcache, but opcache which is built in is another option, untested.

*Important: Update the browscap.ini file located in xampp\php\extras\ Since xampp was designed for development, they have no reason to update it. The browscap.ini file in the xampp dir is dated 11 Dec 2009. Updating the browscap.ini also resolved a css issue on one of my pages. Share buttons and a few other things are working better as well.

Go to http://browscap.org/ and download php_browscap.ini or full_php_browscap.ini, and overwrite the old one in xampp\php\extras\. I personally chose php_browscap.ini.

If your on a Windows box, you'll need to dump some modules to slow the leaking.

My httpd.conf setting:

Code: Select all
#LoadModule dav_lock_module modules/mod_dav_lock.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so
LoadModule filter_module modules/mod_filter.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule ssl_module modules/mod_ssl.so (non-ssl users)
#LoadModule status_module modules/mod_status.so
#LoadModule version_module modules/mod_version.so

#CustomLog "logs/access.log" combined (disable if you don't need use it, save resources)

EnableMMAP off
EnableSendfile off

mod_expire & mod_deflate.  I cleaned all this up as well.  These settings are from GTMetrix.  I have these setting in my Apache conf file, if you're on a host use .htaccess

<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE text/text
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType application/javascript "access plus 1 year"

Okay, on to xampp\apache\conf\. I'll be skipping security, extrahttpd-default.conf, and httpd-xampp.conf.

httpd-mpm.conf. Trial and error. I'm still in the testing phase (live site), but my Apache hasn't crashed in a week, moving forward.

Code: Select all
<IfModule mpm_winnt_module>
    ThreadsPerChild        400
    MaxConnectionsPerChild 60000

ThreadsPerChild at 400 works for me on an average. We took a hard hit last week, and had to raise it to 900 for about three days. We plan to raise it higher after we finish testing the MaxConnectionsPerChild settings. Before the new settings, our MaxConnectionsPerChild was set at 20000, and still unstable. We're at 60000 now with stability. Our goal is not remove the MaxConnectionsPerChild directive, but to have it restart Apache on a daily basis, and not multiple times a day. You can test MaxConnectionsPerChild at unlimited, but I personally think Windows / Apache / memory leak will crash at some point.

Back to PHP for a minute. I found in different arenas, that copying certain .dll to the system folders were not recommended. I decided to go against the grain and test. libmysql.dll is embedded in the new versions of php. If you copied the old file to your Windows system folders, remove it, and any other old files that are from different versions.

Copying new files. I copied all .dll's in the php directory to Windows, system32, and sysWOW65.

I repeated the process for all of the .dll's in xampp\php\ext. If Windows needed a file, I wasn't sure which file name it would look for, so I copied both. Example:

php_gd2.dll and gd2.dll (copy to a different location, and rename)

I copied the usual to xampp\apache\bin libeay32.dll, php5apache2_4.dll, php5ts.dll, and ssleay32.dll. Never stopped the crashing in the past to be honest with you, but what do I know.

Windows Environment Variables: add the php path

Variable name: path

Variable Value: C:\xampp\php

Reboot server.

I hope this tutorial help those with Windows / memory leak / ocpcode cache issues. If your Windows server is 100% stable with medium to high traffic, without the MaxConnectionsPerChild directive, please share your settings.
User avatar
Posts: 5
Joined: 10. May 2014 07:54
Operating System: 2008 R2 x64 / Windows 7 x64

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 64 guests