huanayun
hengtianyun
vps567
莱卡云

解决Apache 2.2.x在Windows 2003上的内存泄露问题 -云主机博士

PikPak

推荐阅读:

[AI-人工智能]免翻墙的AI利器:樱桃茶·智域GPT,让你轻松使用ChatGPT和Midjourney - 免费AIGC工具 - 拼车/合租账号 八折优惠码: AIGCJOEDISCOUNT2024

[AI-人工智能]银河录像局: 国内可靠的AI工具与流媒体的合租平台 高效省钱、现号秒发、翻车赔偿、无限续费|95折优惠码: AIGCJOE

[AI-人工智能]免梯免翻墙-ChatGPT拼车站月卡 | 可用GPT4/GPT4o/o1-preview | 会话隔离 | 全网最低价独享体验ChatGPT/Claude会员服务

[AI-人工智能]边界AICHAT - 超级永久终身会员激活 史诗级神器,口碑炸裂!300万人都在用的AI平台

之前,头一次在Windows Server安装这样的环境,系统运行不久后,就经常发生httpd.exe 的Memory Leak. 在网上找了很久,这个问题终于解决了,httpd.conf配置如下:

<IfModule mpm_winnt.c> 
Win32DisableAcceptEx
ThreadsPerChild 100
MaxRequestsPerChild 1000
MaxMemFree 16
ThreadLimit 100
ThreadStackSize 8192
KeepAliveTimeout 2
MaxKeepAliveRequests 10
</IfModule>

如此设置成功后,不要使用“restart", 因为使用restart的话,Apache只会停掉child thread, 再将老的parent thread复制后,生成一个新的child thread. 也就是说:你的threads设置没有生效。解决的办法是:Stop Sevice(别太心疼停服务),然后再Start Service。这样,parent tread就是一个新的进程号了,如果你不相信,可以在stop前、后,使用如下命令测试:

tasklist /FI "imagename eq httpd.exe"

当设置生效后,你就会从error.log中看到如下内容:
[Thu May 19 22:47:13 2012] [notice] Apache/2.2.4 (Win32) configured -- resuMing normal operations
[Thu May 19 22:47:13 2012] [notice] Server built: Jan 9 2007 23:17:20
[Thu May 19 22:47:13 2012] [notice] Parent: Created child process 3752
[Thu May 19 22:47:13 2012] [notice] Disabled use of AcceptEx() WinSock2 API
[Thu May 19 22:47:13 2012] [notice] Child 3752: Child process is running
[Thu May 19 22:47:13 2012] [notice] Child 3752: Acquired the start mutex.
[Thu May 19 22:47:13 2012] [notice] Child 3752: Starting 100 worker threads.
[Thu May 19 22:47:13 2012] [notice] Child 3752: Listening on port 80.
[Thu May 19 22:48:00 2012] [error] [client 222.178.216.188] Invalid URI in request Connection: Keep-Alive
[Thu May 19 22:49:54 2012] [notice] Child 3752: Process exiting because it reached MaxRequestsPerChild. Signaling the parent to restart a new child process.
[Thu May 19 22:49:54 2012] [notice] Parent: Received restart signal -- Restarting the server.
[Thu May 19 22:49:54 2012] [notice] Apache/2.2.4 (Win32) configured -- resuming normal operations
[Thu May 19 22:49:54 2012] [notice] Server built: Jan 9 2007 23:17:20
[Thu May 19 22:49:54 2012] [notice] Parent: Created child process 1756
[Thu May 19 22:49:54 2012] [notice] Disabled use of AcceptEx() WinSock2 API
[Thu May 19 22:49:54 2012] [notice] Child 1756: Child process is running
[Thu May 19 22:49:55 2012] [notice] Child 3752: Released the start mutex
[Thu May 19 22:49:55 2012] [notice] Child 1756: Acquired the start mutex.
[Thu May 19 22:49:55 2012] [notice] Child 1756: Starting 100 worker threads.
[Thu May 19 22:49:55 2012] [notice] Child 3752: Waiting for 100 worker threads to exit.
[Thu May 19 22:49:55 2012] [notice] Child 1756: Listening on port 80.
[Thu May 19 22:50:03 2012] [notice] Child 3752: All worker threads have exited.
[Thu May 19 22:50:03 2012] [notice] Child 3752: Child process is exiting
注意:
当达到MaxRequestsPerChild时,apache的parent thread会启动一个新的child thread,这时你的系统中会停有3个httpd.exe进程,直到上一个进程的所有child thread都结速后,进程才会退出。
另外,上面的error log级别是:LogLevel warn

宝塔服务器面板,一键全能部署及管理,送你3188元礼包,点我领取

bwg Vultr justhost.asia racknerd hostkvm pesyun Pawns


本文标签属性:

Apache:apache默认端口

Windows 2003:windows2003还能用吗

原文链接:,转发请注明来源!