日期:2014-05-20  浏览次数:20717 次

servlet部属到服务器上面运行一段时间后遇到问题
把写好的 servlet 部属到服务器上面后运行一段时间会提示 内存溢出 ,不知道什么原因,webloic服务软件。运行一段时期内才提示 内存溢出。下面是那个servlet代码,请高手看看有没有逻辑错误,谢了!

  private static final int MINUTE = 1;
  private static List sessionList = new ArrayList();


  protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  Calendar calendar = Calendar.getInstance();
  //判断删除超时时间。
  int i = 0;
  while (i < sessionList.size()) {

  if (((Calendar) sessionList.get(i)).get(Calendar.DATE) != calendar.get(Calendar.DATE)) {
  sessionList.clear();
  break;
  }
  if (((Calendar) sessionList.get(i)).get(Calendar.HOUR) != calendar.get(Calendar.HOUR)) {
  sessionList.remove(i);
  continue;
  }
  if (calendar.get(Calendar.MINUTE) - ((Calendar) sessionList.get(i)).get(Calendar.MINUTE) > MINUTE) {
  sessionList.remove(i);
  continue;
  }

  i++;
  }
  sessionList.add(calendar);
  System.out.println("sessionList:" + sessionList.size());

  //检查请求文件是否存在
  String reportName = request.getParameter("ReportName");
  String reportFileName = "/" + reportName + ".raq";
  //获得动态文件夹存放路径
  File file = new File(request.getSession().getServletContext().getRealPath("/") + "/reportFiles" + reportFileName);
  if (file.exists()) {
  System.out.println("fileExist");
  } else {
  System.out.println(request.getSession().getServletContext().getRealPath("/") + "/reportFiles" + reportFileName);
  response.sendRedirect("noFileError.jsp");
  return;
  }


  Properties properties = new Properties();
  properties.load(getClass().getResourceAsStream("/Logincount.properties"));
  //超过读取.properties文件限制个数跳转错误页面 <
  if (sessionList.size() > Integer.parseInt(properties.getProperty("LOGINCOUNT"))) {
  response.sendRedirect("loginOver.jsp");
  return;
  } else {
  response.sendRedirect("ShowReport.jsp?ReportName=" + request.getParameter("ReportName") + "&ID=" +
  request.getParameter("ID") + "&SWJG_DM=" + request.getParameter("SWJG_DM"));

  }
  } 



------解决方案--------------------
java虚拟机内存(默认好像是64m,记不大清楚了)设置大点看看能不能解决