0 Replies Latest reply on Mar 16, 2004 1:17 AM by hzxia

    Help me! java.lang.OutOfMemoryError!

    hzxia

      My Jboss throw a "java.lang.OutOfMemoryError " often! So I write a jsp to test it!

      ===============================================
      <%@ page language="java" %>
      <%@ page contentType="text/html; charset=GBK" %>
      <%@ page import="java.io.*"%>
      <%
      Integer j = (Integer)session.getAttribute("i");
      if(j == null)
      {
      j = new Integer(1);
      }
      int i = j.intValue();

      String fileName = (String)session.getAttribute("fileName");
      if(fileName == null)
      {
      fileName = "testjj1.jsp";
      }

      if(i > 100000)
      {
      fileName = "";
      }
      %>


      Test.JSP
      <meta http-equiv="refresh" content="0;url=<%=fileName%>">


      <%
      String filePath = getServletContext().getRealPath("/");
      //String filePath = "D://bea//weblogic81//samples//server//examples//src//test//";
      File file1 = new File(filePath + "testjj.jsp");

      System.out.println((new java.util.Date()).toString() + " -- jj -- " + i);
      filePath = filePath + "testjj" + i + ".jsp";
      File file = new File(filePath);

      InputStream stream = new FileInputStream(file1);
      OutputStream bos = new FileOutputStream(file);
      int bytesRead = 0;
      byte[] buffer = new byte[8192];
      while ((bytesRead = stream.read(buffer, 0, 8192)) != -1)
      {
      bos.write(buffer, 0, bytesRead);
      }
      bos.close();
      stream.close();

      file = null;
      file1 = null;

      i++;
      session.setAttribute("i", new Integer(i));
      session.setAttribute("fileName", "testjj" + i +".jsp");
      %>
      Just for Test!



      ===============================================

      When the jsp number is 4325, Jboss throw a "java.lang.OutOfMemoryError
      "!

      What can I do? Who can help me!