我得到了一个java.lang.OutOfMemoryError: Java heap space
,我不知道如何避免它。我正在写出我认为基本上是套接字缓冲区的内容。我认为是javax.servlet.jsp.JspWriter
。
但是,当我尝试编写非常大的 HTML 文件(约 700,000 行)时,我得到一个java.lang.OutOfMemoryError: Java heap space
. 我很困惑为什么框架不只是刷新到套接字。(Marsha, Marsha, Marsha) 开个玩笑,我可以让它刷新到套接字,而不是仅仅增加缓冲区。
我正在使用 JSF 1.1。
注意,我确实尝试添加这个 web.xml:
<context-param>
<param-name>facelets.BUFFER_SIZE</param-name>
<param-value>500000</param-value>
</context-param>
它似乎没有改变任何东西。
这是我的代码示例:
<html>
<f:view>
<head>
<title>Test</title>
</head>
<body id="page_body"
<h:form id="form">
<%
String s;
for (int i = 0; i < rowCount; i++) {
s = data.get(i);
out.println(s);
//flush after on every thousandths row.
//if(i%1000==1)
// out.flush();
} // for loop
%>
</h:form>
</body>
</f:view>
</html>
这是我得到的例外:
org.apache.jasper.JasperException: org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.OutOfMemoryError: Java heap space
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
test.CustomLocaleRemapViewHandler.renderView(CustomLocaleRemapViewHandler.java:94)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
test.CustomFilter.doFilter(CustomFilter.java:46)
test.CustomFilter2.doFilter(CustomFilter2.java:81)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
root cause
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.OutOfMemoryError: Java heap space
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:746)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
org.apache.jsp.test2_jsp._jspService(test2_jsp.java:122)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
test.CustomLocaleRemapViewHandler.renderView(CustomLocaleRemapViewHandler.java:94)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
test.CustomFilter.doFilter(CustomFilter.java:46)
test.CustomFilter2.doFilter(CustomFilter2.java:81)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
root cause
javax.servlet.ServletException: java.lang.OutOfMemoryError: Java heap space
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.test_jsp._jspService(test_jsp.java:745)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:746)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
org.apache.jsp.test2_jsp._jspService(test2_jsp.java:122)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
test.CustomLocaleRemapViewHandler.renderView(CustomLocaleRemapViewHandler.java:94)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
test.CustomFilter.doFilter(CustomFilter.java:46)
test.CustomFilter2.doFilter(CustomFilter2.java:81)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
root cause
java.lang.OutOfMemoryError: Java heap space
java.util.Arrays.copyOf(Unknown Source)
java.io.ByteArrayOutputStream.grow(Unknown Source)
java.io.ByteArrayOutputStream.ensureCapacity(Unknown Source)
java.io.ByteArrayOutputStream.write(Unknown Source)
sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
sun.nio.cs.StreamEncoder.implWrite(Unknown Source)
sun.nio.cs.StreamEncoder.write(Unknown Source)
java.io.OutputStreamWriter.write(Unknown Source)
java.io.PrintWriter.write(Unknown Source)
java.io.PrintWriter.write(Unknown Source)
test.CustomWrapper$CustomPrintWriter.write(CustomWrapper.java:82)
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:119)
org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:336)
java.io.Writer.write(Unknown Source)
com.sun.faces.renderkit.html_basic.HtmlResponseWriter.write(HtmlResponseWriter.java:519)
com.sun.faces.taglib.jsf_core.ViewTag.doAfterBody(ViewTag.java:196)
org.apache.jsp.test_jsp._jspService(test_jsp.java:725)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
顺便说一句,BalusC,如果你在那里,请帮忙。没压力,呵呵。您回答了大约一半的 JSF 问题。
格雷