public function test(){
$m=M('tag');
$q=$this->_get("q");
if ($q){
$tag=$m->where("status=1 and name like '%".$q."%'")->field('tagId as id,name')->order('count')->limit(20)->select();
}
else{
$tag=$m->where("status=1")->field('tagId as id,name')->order('count')->limit(20)->select();
}
$this->ajaxReturn($tag,'JSON');
}描述:方位其他应用时很正常,访问这个方法时连续访问几次,内存就会很快增加,一个请求需要几分钟才能返回数据。甚至因为内存耗尽而崩溃。max_execution_time = 30
max_input_time = 60
memory_limit = 360Mapache采用的是prework模式,设置如下:Timeout 60
KeepAlive On
MaxKeepAliveRequests 10
KeepAliveTimeout 5
## Server-Pool Size Regulation (MPM specific)
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 100
MaxRequestsPerChild 500
</IfModule>tag表里只有是6条记录和3000条记录时,问题是一样的。执行的查询语句在mysql下执行时,经过多次实验时间可以忽略不计。 $q=$this->_get("q");
$tag=array();
mysql_connect('localhost:3306', huiyi', '*****')
or die("Could not connect: " . mysql_error());
mysql_select_db("huiyi");
$result = mysql_query("select tagId as id,name from hy_tag where status=1 and name like '%".$q."%' limit 20")
or die("Query failed: " . mysql_error());
$i = 0;
while ($row = mysql_fetch_assoc($result)) {
array_push($tag, $row);
}
$this->ajaxReturn($tag,'JSON'); 附件 1.png ( 89.61 KB 下载:10 次 )
ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。