我正在开发一个使用 Tomcat 6 作为 Web 服务器的基于 Java 的 Web 应用程序。通常,我们有一个 MySQL 后端,但在少数情况下,我们需要使用 MS SQL 来为我们的客户提供服务。在执行我们对这些 MS SQL 实例之一的最新升级时,我在访问 Web 应用程序的某些页面时开始出现 java 内存不足错误。通常在返回较大的结果集时发生,但并非总是如此。
在与我的 PC 上的本地实例相同的 Web 应用程序设置中,我没有收到此错误,这让我相信这是一个环境问题。我在 Tomcat 6 配置中尝试了许多不同的 Java 设置,但没有解决问题。
环境是具有 4GB RAM 的 32 位机器。我已经为 Tomcat 6 配置了以下内容: -XX:MaxPermSize=512m -Xnoclassgc 初始内存池:1024 最大内存池:1024
我也尝试增加 MaxPermSize,但这会导致 Tomcat 无法启动。
同样,我尝试将 -Xms -Xmx 设置为每个 256m、每个 512m 等。
我的本地计算机是 64 位的,具有 4GB RAM。我已经为 Tomcat 6 配置了以下内容: -XX:MaxPermSize=512m -Xnoclassgc 初始内存池:1024 最大内存池:1024
这可能是新升级中的 SQL 语句的问题吗?我不相信这种情况,因为错误不会发生在我的本地实例上。我相信它与环境有关,但无法弄清楚问题所在。
有人有建议吗?
这是记录的错误:
2012-09-19 11:44:54,745 [ http-80-7] ERROR org.apache.jsp.siteManager.util.error_jsp: javax.servlet.ServletException: java.lang.OutOfMemoryError: unable to create new native thread
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
at org.apache.jsp.doc.doc.index_jsp._jspService(index_jsp.java:1106)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at com.djinnsoft.jade.sitetree.Sitetree.forward(Sitetree.java:405)
at com.djinnsoft.jade.sitetree.Sitetree.forward(Sitetree.java:344)
at com.djinnsoft.jade.sitetree.RootServlet.service(RootServlet.java:124)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.springboard.ram.report.ReportSecurityFilter.doFilter(ReportSecurityFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Unknown Source)
at com.microsoft.sqlserver.jdbc.TimeoutTimer.start(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(Unknown Source)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at com.djinnsoft.jade.data.record.SQLUtil.ExecuteQuery(SQLUtil.java:236)
at com.djinnsoft.jade.data.record.SQLUtil.ExecuteQuery(SQLUtil.java:207)
at com.djinnsoft.jade.data.record.RecordSource.find(RecordSource.java:184)
at com.djinnsoft.jade.data.record.RecordSource.find(RecordSource.java:148)
at com.djinnsoft.jade.content.data.DatabaseContentSource.createVersions(DatabaseContentSource.java:804)
at com.djinnsoft.jade.content.data.DatabaseContentSource.access$2900(DatabaseContentSource.java:42)
at com.djinnsoft.jade.content.data.DatabaseContentSource$8.process(DatabaseContentSource.java:747)
at com.djinnsoft.jade.data.record.SQLEnvironment.execute(SQLEnvironment.java:70)
at com.djinnsoft.jade.content.data.DatabaseContentSource.findImpl(DatabaseContentSource.java:672)
at com.djinnsoft.jade.content.GenericContentSource.findImpl(GenericContentSource.java:1077)
at com.djinnsoft.jade.content.GenericContentSource.find(GenericContentSource.java:1186)
at com.djinnsoft.jade.content.GenericContentSource.find(GenericContentSource.java:1200)
at com.djinnsoft.jade.content.GenericContentSource.find(GenericContentSource.java:1025)
at com.djinnsoft.jade.content.taglib.ContentBaseTag.findItem(ContentBaseTag.java:166)
at com.djinnsoft.jade.content.taglib.ContentTag.doStartTag(ContentTag.java:500)
at org.apache.jsp.doc.doc.index_jsp._jspx_meth_content_005faction_005f12(index_jsp.java:7637)
at org.apache.jsp.doc.doc.index_jsp._jspx_meth_c_005fforEach_005f6(index_jsp.java:6299)
at org.apache.jsp.doc.doc.index_jsp._jspx_meth_c_005fotherwise_005f3(index_jsp.java:4816)
at org.apache.jsp.doc.doc.index_jsp._jspx_meth_c_005fchoose_005f3(index_jsp.java:4395)
at org.apache.jsp.doc.doc.index_jsp._jspx_meth_c_005fotherwise_005f2(index_jsp.java:4363)
at org.apache.jsp.doc.doc.index_jsp._jspx_meth_c_005fchoose_005f2(index_jsp.java:4278)
at org.apache.jsp.doc.doc.index_jsp._jspx_meth_forms_005fpopulateResult_005f0(index_jsp.java:4244)
at org.apache.jsp.doc.doc.index_jsp._jspService(index_jsp.java:961)
... 32 more