gpt4 book ai didi

将 MS SQL 2005 DB 与 Tomcat 6 一起使用时出现 Java 内存不足错误

转载 作者:行者123 更新时间:2023-12-01 05:07:30 27 4
gpt4 key购买 nike

我正在开发一个基于 java 的 Web 应用程序,它使用 Tomcat 6 作为 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

最佳答案

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

这通常表明 OOM 出现在 native 内存中,而不是 Java 堆中。这意味着操作系统无法分配线程。
这可能意味着:

  • 您运行的线程过多,并且超出了某些操作系统限制(您使用的 64 位计算机的线程限制与 32 位计算机不同)或

  • 您的一个线程在初始化时使用了太多内存,并且崩溃了(我无法更准确地描述这一点)。

您说您无法重现此内容,但这是否可能是您没有网络服务器的负载,以便能够在本地重现此内容?我的意思是,也许在部署的服务器实例中负载太重,并发请求太多(太多应用程序线程?),这导致了崩溃?

关于将 MS SQL 2005 DB 与 Tomcat 6 一起使用时出现 Java 内存不足错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12498752/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com