哪位高手帮我看看,问题究竟出在哪里?一运行下面的程序,服务器医生就发出警告,说是占用1500多的内存。。。。。

lingzp 2005-05-07 10:16:38

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="40%" height="85"><img src="../Templates/images/news_company.gif" width="135" height="100"></td>
<td width="60%">
<img border="0" src="images/1.jpg" width="456" height="8"></td>
</tr>
</table>
<!--#include file="../admin/conn.asp"-->
<%
const MaxPerPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim pageurl

if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if

sql="selec * from xxxx where bigclassname='xxxx' order by newsid desc"
rs.open sql,conn,1,1

%>
<%
if rs.eof and rs.bof then
response.write "<p align='center'></p>"
else
PageUrl="company.asp"
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if

end if
%>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" height="57">
<tr bgcolor="#Ffffff">
<td valign="left" height="5">
<% if currentPage=1 then
'showpage totalput,MaxPerPage,PageUrl
showContent
showpage totalput,MaxPerPage,PageUrl
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,PageUrl
else
currentPage=1
showContent
showpage totalput,MaxPerPage,PageUrl
end if
end if
rs.close
end if

sub showContent
dim i
i=0
%>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="100%" height="39" align="center" valign="top" bordercolor="#D2F0FF"> <div align="center">
<table width="90%" cellpadding="0" bordercolor="#8CDBFF" class="d" style="border-collapse: collapse" border="1">
<%do while not rs.eof %>
<tr bordercolor="#8CDBFF" bgcolor="#FFFFFF">
<td width="599" height="20" align="left">· <a href="../show.asp?newsid=<%=rs("newsid")%>" target="_blank"><%=rs("title")%></a><%if rs("image")>0 then%><font color=red>(图)</font><%end if%></td>
<td width="79" align="left"> <%=datevalue(rs("updatetime"))%></td>
</tr>
<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="middle" height="15">
<%
end sub

rs.close
set rs=nothing
conn.close
set conn=nothing

function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<br> "
response.write "<form method=Post action="&filename&">"
response.write "<p align='center'> "
if CurrentPage<2 then
response.write "<font color='#000080'>第一页 上一页</font> "
else
response.write "<a href="&filename&"?page=1>第一页</a> "
response.write "<a href="&filename&"?page="¤tPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write "<font color='#000080'>下一页 尾页</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
response.write "下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write "<font color='#000080'> 页次:</font><strong><font color=red>"¤tPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
response.write "<font color='#000080'> 共<b>"&totalnumber&"</b>篇文章 <b>"&maxperpage&"</b>篇文章/页</font> "
response.write " <font color='#000080'>转到:</font><input type='text' name='page' size=3 maxlength=10 value="¤tpage&">"
response.write "<input class=buttonface type='submit' value='Goto' name='cndok'>   </span></p></form>"

end function
%>
</td>
</tr>
</table>
...全文
152 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
qunluo 2005-05-12
  • 打赏
  • 举报
回复
兄弟,一定换为存储过程分页,我保证你的程序一下子好很多,我曾经和你一样碰到过这样的问题,服务器占用资源100%,直线显示情况,很晕的,当时!

后来,优化了一下程序,没太多用处!

但是没想到一分页一改?既然、既然下到30-40%

想想自己都不敢相信?你真的要试试!

你的这个分页是地球人都知道的那种?但是在数据量大的时候,等着死吧!
fuzi83 2005-05-11
  • 打赏
  • 举报
回复
会不会是出现死循环阿??
lingzp 2005-05-08
  • 打赏
  • 举报
回复
不错,同样的程序,在读取的数据量小时,就不会发出警告!
据说通常未释放rs和conn变量会出现死机的现象,可是天地良心,大家都看到了,我是
显式地释放了这些资源的。。。

能肯定问题是出在程序代码上吗?拜托各位高手能否说的具体一点,不胜感激!
---- 如果我能想出来就不会来这里请教了!!
如意唐伯虎 2005-05-08
  • 打赏
  • 举报
回复
up
zj01 2005-05-07
  • 打赏
  • 举报
回复
2个原因:
1。数据库损坏
2。读取过多的数据,效率底下

好好研究你的程序,做到最少的读取,最少的运算,不然对于服务器来说你这样的程序是灾难。
kingcpu 2005-05-07
  • 打赏
  • 举报
回复
这种问题要你自己想了

高手和低手的区别仅仅在于细节!

可以想想:你要把整个数据的内容都取出来啊!还不仅是这个数据呢
mingyuexingguang 2005-05-07
  • 打赏
  • 举报
回复
数据库多少数据,太多的话自己找个其他方法分页吧

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧