Author |
|
asinsh
Joined: 10 Dec 2005 Posts: 24
|
Posted: Thu 16 Mar '06 4:02 Post subject: apache 2.2 memory usage (leak??) |
|
|
I'm running apache 2.2 on a winxp box (thanks stefen!!) with mysql 5.0.19 and php 5.1.2 (with 2gb of RAM) to drive a couple of phpbb forums. My forums have pretty low usage (they only have about 200 users total and only have about 15 posts per day). I don't do much of anything else on this particular computer.
I noticed a few times recently in the apache error log entries like this:
Code: | FATAL: erealloc(): Unable to allocate 1572864 bytes |
I also just checked the task manager and I find the following:
- there are two apache.exe processes listed as running (why two rather than one??)
- one of the processes is taking about 140MB of memory and the other is taking 10MB of memory
- mysql is taking about 45MB of memory
So my question: is all of that normal or is there something wrong with apache taking up 150MB memory? And if that's wrong, how can I troubleshoot and fix it?
Thanks. |
|
Back to top |
|
asinsh
Joined: 10 Dec 2005 Posts: 24
|
Posted: Thu 16 Mar '06 4:10 Post subject: |
|
|
OK, I just added the following to my httpd.conf file:
Code: |
EnableMMAP off
EnableSendfile off
Win32DisableAcceptEx
|
And that seems to have reduced the memory usage to 10MB fo rone of the apache processes and 17MB for hte other, which is a lot lower. Still two processes though...is that normal? Any problem with my adding those lines to my .connf file? |
|
Back to top |
|
asinsh
Joined: 10 Dec 2005 Posts: 24
|
Posted: Thu 16 Mar '06 4:37 Post subject: |
|
|
Spoke too soon. After 20 minutes, apache is now taking 80MB for one process and 10MB for the other. So it seems to leak memory. Any ideas? Or is this normal and ok? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Thu 16 Mar '06 10:31 Post subject: |
|
|
It can be normal! It depends on what apps you are running. If you have complex PHP Programmes it can be. Even a complex SQL Traffic causing high memory usage.
How many users access the webserver? |
|
Back to top |
|
asinsh
Joined: 10 Dec 2005 Posts: 24
|
Posted: Thu 16 Mar '06 11:42 Post subject: |
|
|
James Blond wrote: | It can be normal! It depends on what apps you are running. If you have complex PHP Programmes it can be. Even a complex SQL Traffic causing high memory usage.
How many users access the webserver? |
I have nothing running on this server other than two phpbb2 boards. One of those boards has 20 users (of which only about 5 visit the site per day) and the other has about 200 users (of which only about 40 visit the site per day). In total I would guess there are less than 20 posts per day. Almost no non-users hit the site since I allow only registered users to view anything. AWSTATS reports that I am delivering about 30MB of bandwidth per day.
So there really isn't a whole lot of traffic and there aren't a lot of php programs running (only two phpbb2 boards).
I just checked mem usage at 4am when noone had been on either site for hours and I find one apache process still at 10mb and the other has climbed all the way back to 170mb. Is this really normal under the circumstances? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Thu 16 Mar '06 12:49 Post subject: |
|
|
FATAL: erealloc(): Unable to allocate 1572864 bytes
I seen this when php calld an external program (.exe).
Two apache processes is how it works. A parent process, and a child which handles the requests. Within the child process each request is handled by a separate thread.
And your memory usage is not that high. Here it grows from 20 Mb to over 140Mb (also with 2.0.55). The same I see with my other server Sambar.
It is kown that php can leak memory when run as a Apache module. You can try to run php as cgi and see how that goes. But as cgi it it can be a bit slower.
Steffen |
|
Back to top |
|
asinsh
Joined: 10 Dec 2005 Posts: 24
|
Posted: Thu 16 Mar '06 18:10 Post subject: |
|
|
Thanks for those responses, Steffen and James.
James, you gave me links to various directives I can use to limit memory usage. Steffen, you said this:
Steffen wrote: | ...And your memory usage is not that high. Here it grows from 20 Mb to over 140Mb (also with 2.0.55). The same I see with my other server Sambar.
It is kown that php can leak memory when run as a Apache module. You can try to run php as cgi and see how that goes. But as cgi it it can be a bit slower... |
I have 2 gb of RAM so I have no problem with apache using 180MB. I was just trying to make sure nothing is wrong. Given that I have plenty of RAM, am I best off leaving things the way I have them rather than limiting RAM and processes as described in the directives James linked to? I am guessing I should leave everything alone as it is, correct? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Thu 16 Mar '06 22:52 Post subject: |
|
|
If you have such a lot of memory don't limit the apache. |
|
Back to top |
|
asinsh
Joined: 10 Dec 2005 Posts: 24
|
Posted: Mon 27 Mar '06 22:50 Post subject: FATAL: erealloc(): error solved... |
|
|
Steffen wrote: | FATAL: erealloc(): Unable to allocate 1572864 bytes
I seen this when php calld an external program (.exe)... |
Apcahe was giving me that error and restarting the service every few hours. I was finally able to fix that problem by commenting out the following directive in my conf file:
Win32DisableAcceptEx
I had put that directive in there to deal with this warning I was getting:
Code: | [Mon Mar 13 11:09:19 2006] [warn] (OS 64)The specified network name is no longer available. : winnt_accept: Asynchronous AcceptEx failed. |
Now that I have commented out that directive, I am once again getting those warnings from time to time but I no longer have fatal errors that restart the service.
Anyone know how I can more safely address the warnings I am getting, or should I just ignore those warnings? |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Thu 30 Mar '06 0:56 Post subject: |
|
|
I get the warnings too and it does not harm here.
Steffen |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 11 Apr '06 12:30 Post subject: |
|
|
Another idea is only to load needed modules in Apache. Comment out all unneeded modules that "saves" some memory. |
|
Back to top |
|