tomcat的内存分配是默认的64M
程序代码如下:
/*
<%
SQLProxy sqlp=new SQLProxy("name");
      if(null==sqlp){
      out.println("无法与数据库建立连接。");
      return;
      }
      String sql = "";
%>
        <table width="580" border="0" cellspacing="0" cellpadding="0" align="center">
          <%
try{
      sqlCount="select count(*) total from mnnews where classid=" + classid;
              sql = "select * from (select rownum srnum,newsid,title,content,systime from (select * from mnnews where classid="+classid+" order by systime desc)) where srnum ";
              sqlp.getPageBreak(String.valueOf(pageid),sqlCount,sql,15);
              pagecount=sqlp.getAllPage();
              if(pageid > pagecount || pageid < 2){
               pageid=1;
              }
                while(sqlp.nextRow()){
                  newsid = sqlp.getFieldString("newsid");
   %>
          <tr> 
            <td width="16" height="25"><img src="../img/menu_arrow.gif" width="16" height="16"></td>
            <td><a href="show_news.jsp?newsid=<%=newsid%>"><%=sqlp.getField("title")%></a> 
              (<%=sqlp.getFieldString("systime").substring(5,10)%> <font color=red><%=sqlp.getField("count")%></font>次点击)</td>
          </tr>
          <%} //end while
        %>
        </table>
<%wo.freeConnection();%>
*/

解决方案 »

  1.   

    我用下面方法监测到内存的使用情况:
    /*
    Runtime.getRuntime().gc();
    out.println("总数:"+Runtime.getRuntime().totalMemory() +" 剩余:"+ Runtime.getRuntime().freeMemory()+"<br>");
    out.println("使用:"+(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())) ;
    */
    输出结果:总数:20910080 剩余:9619616 使用:11290864 我想一定是我哪个环节有问题,否则,不可能只是那么点操作就导致内存溢出,因为我知道很多公司的海量数据操作都用oracle+jsp+tomcat,所以oracle+jsp+tomcat一定有很好的性能
      

  2.   

    我也有过类似情况反正后来都换WebLogic了,Tomcat就是不行 :(时间一长就玩完,同样程序在WebLogic下运行半年没有重启过....---------
    春困秋乏夏打盹,睡不醒的冬三月 ^^!