<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>https://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>https://jackxiang.com/post//</link>
<title><![CDATA[Apache占用大量内存原因]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Mon, 29 Dec 2008 10:31:07 +0000</pubDate> 
<guid>https://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	问：为什么服务器在连续运行多天后或访问峰值后，进程中的一个Apache.exe占用内存几百兆不减少？<br/><br/>答：用记事本打开apache2&#92;conf&#92;httpd.conf，查找MaxRequestsPerChild，将MaxRequestsPerChild 0改成MaxRequestsPerChild 50即可。<br/><br/>　　通常在“Windows任务管理器－进程”中可以看到两个apache.exe进程，一个是父进程、一个是子进程，父进程接到访问请求后，将请求交由子进程处理。MaxRequestsPerChild这个指令设定一个独立的子进程将能处理的请求数量。在处理 “MaxRequestsPerChild 数字”个请求之后，子进程将会被父进程终止，这时候子进程占用的内存就会释放，如果再有访问请求，父进程会重新产生子进程进行处理。<br/><br/>　　如果MaxRequestsPerChild缺省设为0(无限)或较大的数字(例如10000以上)可以使每个子进程处理更多的请求，不会因为不断终止、启动子进程降低访问效率，但MaxRequestsPerChild设置为0时，如果占用了200～300M内存，即使负载下来时占用的内存也不会减少。内存较大的服务器可以设置为0或较大的数字。内存较小的服务器不妨设置成30、50、100，以防内存溢出<br/><br/><br/><br/>解决方法： 初始化，unset不用的大数据量的变量。适当减小操作数据规模。<br/><br/>检查内存释放状况。<br/><div class="code"><br/>$a=array();<br/>for($i=0;$i&lt;=1000000;$i++)<br/>&#123;<br/>$a&#91;$i&#93;=$i;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&#125;<br/>unset($a);<br/></div><br/><br/>假设我原始占用内存50M<br/>多刷新几次，占用内存到200M，稍后恢复，但不再是50M，而是60M<br/>说明多出10M，看来这有可能是内存泄露引起<br/><br/>找到问题了，是由于MaxRequestsPerChild设置为0的后果<br/>现已经改成200<br/><br/>PHP的unset参看：<br/><br/>http://www.xiangdong.org/blog/post/1520/
]]>
</description>
</item><item>
<link>https://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] Apache占用大量内存原因]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>