logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Memory leak... Apache 2.2
Author
bokehman



Joined: 12 Oct 2006
Posts: 11

PostPosted: Fri 27 Apr '07 10:19    Post subject: Memory leak... Apache 2.2 Reply with quote

Hi all,

I have been running Apache 2 with no problems on a production box for about 2 years without any problem. I have recently upgraded to the to the compiled Apache 2.2 from this site (Windows XP).

The old set-up used to use about 12 Megabytes of RAM. Apache 2.2 starts using about 15 Megabytes of RAM but after running for a couple of days it has commandeered more than 100 Megabytes. Has anyone got any ideas what could be causing this?
Back to top
Kanashii



Joined: 17 Jul 2006
Posts: 155
Location: Porando

PostPosted: Fri 27 Apr '07 10:30    Post subject: Reply with quote

The same on my Apache try run PHP as Fast-CGI or restart apache per hour
Back to top
bokehman



Joined: 12 Oct 2006
Posts: 11

PostPosted: Fri 27 Apr '07 10:39    Post subject: Reply with quote

I'd rather find the problem than run it a a CGI. Also is it normal that 2 iterations of httpd.exe are running at the same time?

This makes me want to go back to my old set-up.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7298
Location: Germany, Next to Hamburg

PostPosted: Fri 27 Apr '07 15:19    Post subject: Reply with quote

Hello!
Apache always run 2 processes. 1 Parent and 1 Child. That is ok. Which version of Apache did you run before? Did you also tried the new Apache from apache.org?
I run Apache from this page on my server. And I don't have such problem.
OK the memory usage can be up to 150 Megs. But my Apache don't crashes. It runs fine since ~ 150 days. I run PHP as module.
Back to top
bokehman



Joined: 12 Oct 2006
Posts: 11

PostPosted: Fri 27 Apr '07 21:34    Post subject: Reply with quote

James Blond wrote:
I run Apache from this page on my server. And I don't have such problem.
OK the memory usage can be up to 150 Megs. But my Apache don't crashes. It runs fine since ~ 150 days. I run PHP as module.
I was using Apache 2.0.54 (which didn't steal all this RAM).

What I don't understand is what is Apache 2.2 doing with all this RAM? Why is it commandeering it?

No I haven't tried the version from the apache website.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Sat 28 Apr '07 17:05    Post subject: re: Apache use of RAM Reply with quote

Apache, by default, is configured to aggressively use memory to gain performance. The default Windows configuration allows up to 250 threads to be created to serve simultaneous requests. Once a thread is created, it remains in memory and ready to serve requests until Apache shuts down.

Not an unreasonable default for modern machines. Figuring $110.USD per gb (based on the incremental cost of 1gb on a low-end Dell server), the presumption is that a web server will use about $11 worth of memory to be "ready for a burst of requests".

This is obviously not your opinion, in light of Apache stealing, commandeering, and otherwise maliciously absconding with your 100mb of memory Wink

Most of the memory is used for stack space in the (up to 250) threads. The default thread stack size on Windows is 1mb, but Windows is very good about keeping the actual stack size down to only the memory which was ever actually "touched" - so even after 250 threads have been created you don't see a total of 250mb, but something smaller. The stack use is much smaller if you don't execute PHP or access a database from within the Apache process.

You can tune Apache down very easily. Changing the ThreadsPerChild value from 250 to a smaller number will make a big difference. Maybe something like 50.

If you really want to trade performance for memory conservation, you can set MaxRequestsPerChild to a non-zero number like 100. Apache will kill off the child process and start a new one (with no residual threads or stacks) every 100 requests with this setting. This is pretty drastic, but it's better than periodically restarting Apache.

It's not clear why you have such different results with Apache 2.0.54. Early versions of Apache had a smaller thread-count for Windows, but the default value was up to 250 by Apache 2.0.54. Maybe your Apache 2.0.54 httpd.conf was changed to use a smaller number of threads?

Another possibility is that you used something other than mod_php with Apache 2.0.54 to run your PHP and database access in separate processes. CGI or FastCGI maybe?

All things being equal, Apache 2.2.4 should be larger and faster than Apache 2.0.54, but more like 10%-20% larger - not ten times as large.

The version here at Apache Lounge is built with MSVC v8, so it is slightly larger (and faster) than the stock Apache from www.apache.org.

I find 140mb to be a typical memory size for Apache 2.2.4 on a 2gb Win2k machine with PHP 5.2.0 via mod_php and MySQL 5.0.38; after being subjected to a sustained heavy load. This is the virtual memory size, but when there is no competition for memory in the machine it is usually the actual memory size as well.

-tom-
Back to top
boterkoek



Joined: 03 May 2007
Posts: 3

PostPosted: Thu 03 May '07 12:53    Post subject: Reply with quote

I have this same problem , but apache just keeps using more and more memory, up the 1.4 GIGS , and then it just crash.

I havent installed anything else then PHP , but in my opinion without php it has the same behaviour

My solution is a batch file that restarts apache 2.2.x (win32) every 6 hours.. but anyone know how to fix this?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7298
Location: Germany, Next to Hamburg

PostPosted: Thu 03 May '07 14:18    Post subject: Reply with quote

Please see the forum rules
without further information we can't help.
Back to top


Reply to topic   Topic: Memory leak... Apache 2.2 View previous topic :: View next topic
Post new topic   Forum Index -> Apache