...not that I really know what a memory leak is, but here's why. I got the alert "Apache has encountered an error and needs to close". When it sounded like the disk stopped churning, XAMPP Control showed that it was still running, I don't know if it was confused or if Windows really wasn't able to stop Apache (that would shock me). So I clicked the "Stop" button. After it showed that Apache stopped, I restarted it.

Before this, I had been trying in vain to get SSI and especially SSI calling a script to work (see this topic). My .shtml page worked fine including the results of the script. However, I couldn't check the .phtml page because Windows foiled me again! I assume it's fine. BTW, it's a simple script, just another version of "Hello, world".

TO SUM UP:

I did remember to stop and start Apache with XAMPP Control after making the changes (SEE PREVIOUS POST).

SSI would NOT show output of a script in an .shtml or .phtml page.

Windows problem shut Apache down.

XAMPP Control showed Apache still running after disk stopped churning, so I clicked "Stop" there, then "Start".

The page I was able to view now shows the output of the script. (It didn't before.)

Windows shuts Apache down again (and keeps doing it).

There is mention in the Apache docs that setting "MaxRequestsPerChild" can be useful to guard against memory leaks taking over all your memory, and right now it is set to "0" (UNLIMITED), the default. Maybe I should set it...what would be a good value? (This is not a production server, but I have a tendency to view pages multiple times in my browser...Firefox, except for fine-tuning CSS) while editing. Do you think this could be a memory-leak problem causing random errors?

Update:

BTW...I just now tried using a port other than 80, though I can't think of any software that would be using that port. It didn't help, just in case anyone was thinking of throwing that suggestion out. I used 8080 and still there is a problem with the server.

In fact, Windows just supposedly stopped Apache, twice. It still showed in XAMPP Control that Apache was still running, so I stopped it there so I wouldn't keep getting alerts that Apache needs to close. Once I get the alert, I can't access anything on localhost, seeming to indicate the server is indeed stopped, but the control program says otherwise.This is very, very strange.

Last edited by CPcoder on 23. February 2006 01:07, edited 1 time in total.

I'm sad to see there are no answers, but here is an interesting update...

I'm learning PHP, so I'm no expert. I can view static HTML pages just fine. If I try to load an HTML & PHP page, sometimes I get the "Apache has encountered an error and needs to close" message right away...other times I can view 1 HTML & PHP page fine, but the error will happen if I try to view another.

I wondered if it could be something in the way I wrote my PHP code, but that doesn't make much sense. 1 of the pages is very simple, just has some simple things like inserting the current date and time, and running an external "Hello, world!" script. Sometimes that causes the error, other times I can view it fine.

Another page is more complicated, prints out the multiplication tables. If this was the only page causing the problem, I could say maybe it's my code. But it's not the only page causing the problem. On the other hand, it does happen with this page every time. But it didn't cause a problem on the standard Apache install, only XAMPP. I should also point out I have no problem viewing any of the pages in the /xampp folder, only my own documents, and only non-static pages.

Could it be a bug in the PHP engine? An inconsistency in the way Apache and/or PHP works on Windows?

## This is the main Apache HTTP server configuration file. It contains the# configuration directives that give the server its instructions.# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.# In particular, see # <URL:http://httpd.apache.org/docs/2.2/mod/directives.html># for a discussion of each configuration directive.## Do NOT simply read the instructions in here without understanding# what they do. They're here only as hints or reminders. If you are unsure# consult the online docs. You have been warned. ## Configuration and logfile names: If the filenames you specify for many# of the server's control files begin with "/" (or "drive:/" for Win32), the# server will use that explicit path. If the filenames do *not* begin# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"# with ServerRoot set to "/xampp/apache" will be interpreted by the# server as "/xampp/apache/logs/foo.log".## NOTE: Where filenames are specified, you must use forward slashes# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").# If a drive letter is omitted, the drive on which Apache.exe is located# will be used by default. It is recommended that you always supply# an explicit drive letter in absolute paths, however, to avoid# confusion.#

# ThreadsPerChild: constant number of worker threads in the server process# MaxRequestsPerChild: maximum number of requests a server process servesThreadsPerChild 250MaxRequestsPerChild 0

## ServerRoot: The top of the directory tree under which the server's# configuration, error, and log files are kept.## Do not add a slash at the end of the directory path. If you point# ServerRoot at a non-local disk, be sure to point the LockFile directive# at a local disk. If you wish to share the same ServerRoot for multiple# httpd daemons, you will need to change at least LockFile and PidFile.#ServerRoot "/xampp/apache"

## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)# MYCHANGE: SWITCHED TO PORT 8080; DIDN'T HELP WINDOWS ERROR#Listen 12.34.56.78:80Listen 8080

# 'Main' server configuration## The directives in this section set up the values used by the 'main'# server, which responds to any requests that aren't handled by a# <VirtualHost> definition. These values also provide defaults for# any <VirtualHost> containers you may define later in the file.## All of these directives may appear inside <VirtualHost> containers,# in which case these default settings will be overridden for the# virtual host being defined.#

## ServerName gives the name and port that the server uses to identify itself.# This can often be determined automatically, but we recommend you specify# it explicitly to prevent problems during startup.## If your host doesn't have a registered DNS name, enter its IP address here.# MYCHANGE: SWITCHED TO PORT 8080; DIDN'T HELP WINDOWS ERRORServerName localhost:8080

## DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.#DocumentRoot "/xampp/htdocs"

## Each directory to which Apache has access can be configured with respect# to which services and features are allowed and/or disabled in that# directory (and its subdirectories). ## First, we configure the "default" to be a very restrictive set of # features. #<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all</Directory>

## Note that from this point forward you must specifically allow# particular features to be enabled - so if something's not working as# you might expect, make sure that you have specifically enabled it# below.#

## This should be changed to whatever you set DocumentRoot to.#<Directory "/xampp/htdocs"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks Includes ExecCGI

# # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None

# # Controls who can get stuff from this server. # Order allow,deny Allow from all

## The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. #<FilesMatch "^\.ht"> Order allow,deny Deny from all</FilesMatch>

## ErrorLog: The location of the error log file.# If you do not specify an ErrorLog directive within a <VirtualHost># container, error messages relating to that virtual host will be# logged here. If you *do* define an error logfile for a <VirtualHost># container, that host's errors will be logged there and not here.#ErrorLog logs/error.log

# # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost> # container, they will be logged here. Contrariwise, if you *do* # define per-<VirtualHost> access logfiles, transactions will be # logged therein and *not* in this file. # CustomLog logs/access.log common

# # If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # #CustomLog logs/access.log combined</IfModule>

<IfModule alias_module> # # Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location. # Example: # Redirect permanent /foo http://www.example.com/bar

# # Alias: Maps web paths into filesystem paths and is used to # access content that does not live under the DocumentRoot. # Example: # Alias /webpath /full/filesystem/path # # If you include a trailing / on /webpath then the server will # require it to be present in the URL. You will also likely # need to provide a <Directory> section to allow access to # the filesystem path.

# # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. # ScriptAlias /cgi-bin/ "/xampp/cgi-bin/"

</IfModule>

## "/xampp/cgi-bin" should be changed to whatever your ScriptAliased# CGI directory exists, if you have that configured.#<Directory "/xampp/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all</Directory>

# # Apache parses all CGI scripts for the shebang line by default.# This comment line, the first line of the script, consists of the symbols# pound (#) and exclamation (!) followed by the path of the program that # can execute this specific script. For a perl script, with perl.exe in# the C:\Program Files\Perl directory, the shebang line should be:

#!c:/program files/perl/perl

# Note you _must_not_ indent the actual shebang line, and it must be the# first line of the file. Of course, CGI processing must be enabled by # the appropriate ScriptAlias or Options ExecCGI directives for the files # or directory in question.## However, Apache on Windows allows either the Unix behavior above, or can# use the Registry to match files by extention. The command to execute # a file of this type is retrieved from the registry by the same method as # the Windows Explorer would use to handle double-clicking on a file.# These script actions can be configured from the Windows Explorer View menu, # 'Folder Options', and reviewing the 'File Types' tab. Clicking the Edit# button allows you to modify the Actions, of which Apache 1.3 attempts to# perform the 'Open' Action, and failing that it will try the shebang line.# This behavior is subject to change in Apache release 2.0.## Each mechanism has it's own specific security weaknesses, from the means# to run a program you didn't intend the website owner to invoke, and the# best method is a matter of great debate.## To enable the this Windows specific behavior (and therefore -disable- the# equivilant Unix behavior), uncomment the following directive:##ScriptInterpreterSource registry## The directive above can be placed in individual <Directory> blocks or the# .htaccess file, with either the 'registry' (Windows behavior) or 'script' # (Unix behavior) option, and will override this server default option.#

## DefaultType: the default MIME type the server will use for a document# if it cannot otherwise determine one, such as from filename extensions.# If your server contains mostly text or HTML documents, "text/plain" is# a good value. If most of your content is binary, such as applications# or images, you may want to use "application/octet-stream" instead to# keep browsers from trying to display binary files as though they are# text.#DefaultType text/plain

# # AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below) # # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # AddHandler cgi-script .cgi

# For files that include their own HTTP headers: #AddHandler send-as-is asis

# For server-parsed imagemap files: #AddHandler imap-file map

# For type maps (negotiated resources): #AddHandler type-map var

# # Filters allow you to process content before it is sent to the client. # # To parse .shtml files for server-side includes (SSI): # (You will also need to add "Includes" to the "Options" directive.) # MYCHANGE: UNCOMMENTED SO I CAN USE SSI AND ADDED .pthml AddType text/html .shtml .phtml AddOutputFilter INCLUDES .shtml .phtml</IfModule>

## The mod_mime_magic module allows the server to use various hints from the# contents of the file itself to determine its type. The MIMEMagicFile# directive tells the module where the hint definitions are located.##MIMEMagicFile conf/magic

## EnableMMAP and EnableSendfile: On systems that support it, # memory-mapping or the sendfile syscall is used to deliver# files. This usually improves server performance, but must# be turned off when serving from networked-mounted # filesystems or if support for these functions is otherwise# broken on your system.##EnableMMAP off#EnableSendfile off

# Supplemental configuration## The configuration files in the conf/extra/ directory can be # included to add extra features or to modify the default configuration of # the server, or you may simply copy their contents here and change as # necessary.

# Secure (SSL/TLS) connectionsInclude conf/extra/httpd-ssl.conf## Note: The following must must be present to support# starting without SSL on platforms with no /dev/random equivalent# but a statically compiled-in mod_ssl.#<IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin</IfModule>

The problem is that line does not exist in my httpd.conf! In fact, the entire section under "<IfModule mpm_winnt_module>" section doesn't exist!

But it exists in oldhttpd.conf. I didn't remove it from httpd.conf myself...I thought those files were identical until you changed httpd.conf (to force you to have a backup). Am I wrong? Do I need to paste the entire "<IfModule mpm_winnt_module>" section into httpd.conf?

Or am I wrong, does this have nothing to do with my problem, and I don't need it? I'm running XP Home. I don't have any other servers installed, or anything that needs to use port 80 (that I'm aware of).

Sorry I'm posting so much information, but I really don't know what the problem is, I'm trying to give you anything which may help. There seem to be several errors in the error log, the one that seems to be significant is "[notice] Parent: child process exited with status 3221225477 -- Restarting.", not that I would know what's significant. I'll rename this thread accordingly. I have searched and tried all other suggestions that could be related, and I'm at my wit's end.

This is one of the more common uses of SSI - to output the results of a CGI program, such as everybody's favorite, a ``hit counter.''

<!--#include virtual="/cgi-bin/counter.pl" -->

This should work fine, it was working before. In fact, it still does work. It is the same way I include the results of a hello-world-type php program. The problem is is, indeed (I just verified about 20 times) the CPU load. I will add the directive to xampp\apache\conf\extra\httpd-mpm.conf between line 63 - 66 as you say.

Still get "Apache has encountered an error and needs to close". This error/the CPU problem always happens with said page. I made a copy but changed it by pasting the PHP code directly into the HTML page, getting rid of the SSI. That page worked once, but on a 2nd try get the CPU problem/error anyway.

I actually see the CPU usage shoot up in the system monitor about 10 seconds after I click the link. I get the "Apache has encountered a problem and needs to close" about 36 seconds after I click the link. (I have my test PHP pages linked from a "home" page so I can easily switch between them if I want to compare.)

Like I said in a previous post, it occassionally happens even with the page that displays the current date and uses SSI to display the results of a hello world PHP script, just much less often. This is definitely a CPU usage issue, but the recommended fix doesn't help.

Just a little more info on the CPU usage/"Apache needs to close" message...

Page w/ date & time, simple "hello world" PHP script via SSI: loads pretty much every time, I only had the problem 1 or 2 times, can't recreate today; loads instantly most of the time, sometimes takes a few extra seconds; with a 1-line script, that shouldn't surprize.

Page that uses SSI to run a "times tables" PHP script: worked once, on standard Apache install, but not on the XAMPP installation; tried it 4 times just now; error message comes up anywhere from 22 seconds to 36 seconds after I try to load the page.

Page with PHP "times tables" script hard-coded into the HTML page: tried it 4 times just now; error message (2 out of 4 times) came up 25 seconds and 35 seconds after I try to load the page; successful page views (2 out of 4 times) took 22 seconds and 25 seconds. (Same script as above page, I just copied from the .php file and pasted into my HTML file.)

Obviously with the CPU issue, longer scripts will show the problem most frequently. I even restarted my computer before doing these last tests.

BTW, I asked in another thread (never got an answer), should I change MaxRequestsPerChild? Right now it is 0 (the default).

apache.org wrote:MaxRequestsPerChild: Like the Unix directive, this controls how many requests a single child process will serve before exiting. However, unlike on Unix, a single process serves all the requests at once, not just one. If this is set, it is recommended that a very high number is used. The recommended default, MaxRequestsPerChild 0, causes the child process to never exit.

The MaxRequestsPerChild directive sets the limit on the number of requests that an individual child server process will handle. After MaxRequestsPerChild requests, the child process will die. If MaxRequestsPerChild is 0, then the process will never expire.

Different default values

The default value for mpm_netware and mpm_winnt is 0.

Setting MaxRequestsPerChild to a non-zero limit has two beneficial effects:

* it limits the amount of memory that process can consume by (accidental) memory leakage; * by giving processes a finite lifetime, it helps reduce the number of processes when the server load reduces.

Note

For KeepAlive requests, only the first request is counted towards this limit. In effect, it changes the behavior to limit the number of connections per child.