Java 根本原因 java.lang.OutOfMemoryError 错误 [英] Java root cause java.lang.OutOfMemoryError error
问题描述
我是 Java 新手,被赋予修复错误的任务,问题如下.如果您提出建议/想法这是什么问题以及我该如何解决这个问题,那就太好了.:
I am new to Java and given the task to fix a bug and the issue is as follows. It would be really great if you give suggestions/ideas what is this issue and how can I fix this.:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:453)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
root cause
javax.servlet.ServletException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.CustMaint.Jsp.ProfProfileDetails_jsp._jspService(ProfProfileDetails_jsp.java:4016)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
root cause
java.lang.OutOfMemoryError
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.17
推荐答案
Tomcat 小伙伴们有话要说:
Here's what the Tomcat guys have to say:
内存不足可以被抛出几个原因:
An Out Of Memory can be thrown by several causes:
一个 servlet 试图加载多个GBytes 文件进入内存肯定会杀死服务器.这类错误必须被认为是我们的一个简单的错误程序.
A servlet trying to load a several GBytes file into memory will surely kill the server. These kind of errors must be considered a simple bug in our program.
补偿数据您的 servlet 尝试加载,您增加堆大小,以便有是没有空间创建堆栈大小对于需要的线程创建.每个人需要的内存线程会因操作系统而异,但可以作为默认情况下高达 2M,在某些操作系统中(如 Debian Sarge)不可还原使用 -Xss
参数.1 规则Thumb,使用不超过 1G 的堆32 位 Web 应用程序中的空间.
To compensate for the data
your servlet tries to load, you
increase the heap size so that there
is no room to create the stack size
for the threads that need to be
created. The memory required by each
thread will vary by OS but can be as
high as 2M by default and in some OS's
(like Debian Sarge) is not reducible
with the -Xss
parameter. 1 Rule of
Thumb, use no more than 1G for heap
space in a 32-bit web application.
深度递归算法也可以导致内存不足问题.在在这种情况下,唯一的修复是增加线程堆栈大小(-Xss
),或者重构算法减少深度,或本地数据每次调用的大小.
Deep recursive algorithms can also
lead to Out Of Memory problems. In
this case, the only fixes are
increasing the thread stack size
(-Xss
), or refactoring the algorithms
to reduce the depth, or the local data
size per call.
一个使用大量的网络应用程序具有许多依赖项的库,或维护大量webapps 可能会耗尽 JVM PermGen空间.这个空间是虚拟机所在的地方存储类和方法数据.在这些情况下,解决方法是增加这个尺寸.Sun VM 有标志-XX:MaxPermSize
允许设置其大小(默认值为 64M)
A webapp that uses lots
of libraries with many dependencies,
or a server maintaining lots of
webapps could exhauste the JVM PermGen
space. This space is where the VM
stores the classes and methods data.
In those cases, the fix is to increase
this size. The Sun VM has the flag
-XX:MaxPermSize
that allows to set its size (the default value is 64M)
对类的硬引用可以防止垃圾收集器从回收内存分配给他们时ClassLoader
被丢弃.这会发生在 JSP 重新编译时,以及webapps 重新加载.如果这些操作在具有这些的 webapp 中很常见各种问题,都会有问题时间,直到 PermGen 空间得到已满并抛出内存不足.
Hard references to classes can prevent the
garbage collector from reclaiming the
memory allocated for them when a
ClassLoader
is discarded. This will
occur on JSP recompilations, and
webapps reloads. If these operations
are common in a webapp having these
kinds of problems, it will be a matter
of time, until the PermGen space gets
full and an Out Of Memory is thrown.
这篇关于Java 根本原因 java.lang.OutOfMemoryError 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!