Apache内存泄漏-未使用PHP

Apache内存泄漏-未使用PHP,apache,powershell,apache2.2,Apache,Powershell,Apache2.2,我的Apache 2.2模块(Windows)似乎喜欢内存,任务管理器显示内存不断增长,直到达到~2GB,然后崩溃。我根本不使用PHP,这不是一个网站,而是一个充当服务器的模块。许多条形码扫描设备将向该服务器发送请求,该服务器将对数据库进行插入、更新、删除和查询。如果我有10-15台设备同时工作,我就会看到这个问题 我正在使用FastMM检测Apache模块中的内存泄漏,FastMM没有报告任何泄漏。如果我故意介绍一个,我可以看到FastMM正在咳嗽一个漏洞 这告诉我Apache并没有向操作系统

我的Apache 2.2模块(Windows)似乎喜欢内存,任务管理器显示内存不断增长,直到达到~2GB,然后崩溃。我根本不使用PHP,这不是一个网站,而是一个充当服务器的模块。许多条形码扫描设备将向该服务器发送请求,该服务器将对数据库进行插入、更新、删除和查询。如果我有10-15台设备同时工作,我就会看到这个问题

我正在使用FastMM检测Apache模块中的内存泄漏,FastMM没有报告任何泄漏。如果我故意介绍一个,我可以看到FastMM正在咳嗽一个漏洞

这告诉我Apache并没有向操作系统释放内存,这只在某些情况下发生。如果我只有1-2台设备,那么这个问题就不会发生。所以,我猜这是由发送到Apache的大量请求引起的

作为临时解决方案,我使用PowerShell(版本2.0或4.0,取决于机器)脚本在达到内存阈值时重新启动Apache。我的PowerShell脚本这样做是为了停止apache进程和服务,并启动它(如果内存已达到ca 0.8GB),这一切都可以正常工作,我测试了它:

# If working set of httpd or httpd#1 is greater than threshold, stop and start
if($procobj.workingset -gt $Threshold)
{
# $ProcName is name of process reported by PowerShell (as httpd, httpd#1, httpd#2, ...)
echo $("Memory for " + $ProcName + " exceeds Threshold");

# Stop httpd process
stop-process -name $MyHTTPD -force

# Stop service $ServiceName (this is name of service in Windows->Services)
echo $("---> Stopping service: " + $ServiceName);
stop-Service $ServiceName;

# Start service $ServiceName (this is name of service in Windows->Services)
echo $("---> Starting service: " + $ServiceName);
start-Service $ServiceName;
}
正如您所看到的,我正在停止httpd进程,然后停止Apache服务,然后启动将产生新httpd进程的服务

此外,以下是我正在使用的Apache设置:

#Commented out these 3 in httpd.conf
#KeepAlive On
#MaxKeepAliveRequests 0
#KeepAliveTimeout 3000

#these are in mod_mpm
# WinNT MPM
<IfModule mpm_winnt_module>
ThreadsPerChild 300
#MaxRequestsPerChild 0
MaxRequestsPerChild 50
#According to Apache documentation, if you get "An operation was
#attempted on something that is not a socket), you should use this to
#disable AcceptEx() WinSock v2 API. See:
# http://httpd.apache.org/docs/2.2/mod/mpm_winnt.html
Win32DisableAcceptEx
</IfModule>
#在httpd.conf中注释掉了这3个
#继续
#MaxKeepAliverRequests 0
#保持3000分钟
#这些是modmpm
#温特MPM
螺纹圆钢300
#MaxRequestsPerChild 0
MaxRequestsPerChild 50
#根据Apache文档,如果您得到“一个操作
#在非套接字的对象上尝试),您应该使用此
#禁用AcceptEx()WinSock v2 API。请参阅:
# http://httpd.apache.org/docs/2.2/mod/mpm_winnt.html
Win32 DisableAcceptex
我知道这应该是临时解决方案,但现在的问题是,尽管任务管理器显示内存不断增长,但我无法检测到任何泄漏


非常感谢,

我的体验与您完全相同,我还使用Memproof检查了我的服务器软件是否存在漏洞,除了在Windows内核中没有发现任何漏洞。我使用MaxRequestsPerChild设置为1000000,每个孩子有1500个线程。使用Apache 2.4,我不必使用powershell脚本来重置它-Apache执行您的sc所做的操作ipt会自动为我执行。这可能是Windows(或Apache)处理重叠连接的方式存在问题。不过,我猜,我们目前使用的解决方案目前运行良好。也许Linux服务器上不会出现这种情况,但我的服务器软件仅在Windows!上运行