如何修复solr中的java.lang.OutOfMemoryError: PermGen空间错误?

huangapple go评论76阅读模式
英文:

How to fix java.lang.OutOfMemoryError: PermGen space in solr?

问题

我们在生产服务器上偶尔会遇到这个错误。在我们重新启动 solr 后,问题会得到解决。但是几天后又会再次发生。

版本信息:

我们同时使用 centos6 和 centos7 机器,centos6 使用 java7,centos7 使用 java8。

solr 版本:5.5.5

        at org.apache.solr.servlet.HttpSolrCall.sendError(HttpSolrCall.java:607)
        at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:475)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:257)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:208)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:499)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.OutOfMemoryError: PermGen space```

<details>
<summary>英文:</summary>

We face this error from time to time in our production servers. This gets solved when we restart solr.
But occurs again after few days.

Version information:

We are using both centos6 and centos7 machines, Centos6 is with java7 and centos7 is with java8.

solr: 5.5.5

```2020-07-16 02:38:18,929 ERROR org.apache.solr.common.SolrException: null:java.lang.RuntimeException: java.lang.OutOfMemoryError: PermGen space
        at org.apache.solr.servlet.HttpSolrCall.sendError(HttpSolrCall.java:607)
        at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:475)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:257)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:208)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:499)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.OutOfMemoryError: PermGen space```

</details>


# 答案1
**得分**: 0

这些信息在WIKI上可以找到:https://cwiki.apache.org/confluence/display/solr/Taking+Solr+to+Production#TakingSolrtoProduction-MemoryandGCSettings

SOLR_JAVA_MEM=&quot;-Xms10g -Xmx10g&quot;

https://lucene.apache.org/solr/guide/8_5/jvm-settings.html

<details>
<summary>英文:</summary>

This info is in the WIKI: https://cwiki.apache.org/confluence/display/solr/Taking+Solr+to+Production#TakingSolrtoProduction-MemoryandGCSettings

    SOLR_JAVA_MEM=&quot;-Xms10g -Xmx10g&quot;

https://lucene.apache.org/solr/guide/8_5/jvm-settings.html

</details>



# 答案2
**得分**: 0

以下是翻译好的内容:

这可能是你的Java应用程序内部的内存泄漏,或者你的应用程序有时需要比允许分配或能够分配的内存更多。

**java.lang.OutOfMemoryError: PermGen** 恰好描述了这一点。

阅读这个:https://www.javainuse.com/java/permgen

简而言之:Permgen是Java虚拟机的一部分(一个内存区域),垃圾收集在其中不是完全自动化的。

你的本地系统管理员应该能够处理内存不足错误。

无论如何,这里有一些建议:

1. Java7和Java8都有32位和64位版本,尝试使用64位版本。
2. 检查Java虚拟机的内存使用情况。
3. 还要检查同一台机器上运行的其他应用程序的内存使用情况。

如果你的Java虚拟机在一段时间内需要越来越多的内存,直到崩溃,因为内存不足,那很可能是程序错误,需要程序员修复。

如果你的Java虚拟机的内存使用情况变化很大,有时内存使用会出现高峰,并导致内存不足错误,只需在你的机器上安装更多内存即可。

编辑:Abhijit Bashetti的回答看起来非常不错,首先尝试这个 :)

<details>
<summary>英文:</summary>

It&#39;s either a memory leak within your Java application or your application sometimes needs more memory than it&#39;s allowed to allocate, or able to allocate.

**java.lang.OutOfMemoryError: PermGen** exactly says this.

Read this: https://www.javainuse.com/java/permgen

In short: Permgen is a part (a memory area) of the Java Virtual Machine were garbage collection isn&#39;t fully automatised.

Your local system admin should be able to handle an **out of memory error**.

Some suggestions for you anyway:

 1. Java7 and Java8 exist as 32bit and 64bit version, try to use the 64bit version.
 2. Check the memory usage of your Java Virtual Machine.
 3. Check also the memory usage of other applications running on the same machine.

If your Java Virtual Machine needs more and more memory over time, until it crashes, because it&#39;s out of memory, it&#39;s probably a program error, which has to be fixed by the programmer.

If your Java Virtual Machine varies a lot in its memory usage, and sometimes there&#39;s a high peak in memory usage, and that&#39;s causing the out of memory error, just install more memory into your machine.

EDIT: Abhijit Bashetti&#39;s answer looks very good, try this first :)

</details>



huangapple
  • 本文由 发表于 2020年8月27日 10:50:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/63608430.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定