Spring Boot application- problem with java.lang.OutOfMemoryError: GC overhead limit exceeded

Spring Boot application- problem with java.lang.OutOfMemoryError: GC overhead limit exceeded

我的 SpringBoot 应用 java.lang.OutOfMemoryError: GC overhead limit exceeded 有问题。

我可以看到如下日志:

  Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: GC overhead limit exceeded.

此外,当我在应用程序中工作时 cpu 非常高 (99%)。 我认为它与 XMX 连接。那么如何检查为该应用程序设置的 xmx 大小呢?或者是其他问题? 提前致谢!

My SpringBoot app have a problem with java.lang.OutOfMemoryError: GC overhead limit exceeded.

I can see log as below:

Handler dispatch failed; nested exception is 
java.lang.OutOfMemoryError: GC overhead limit exceeded. 

这是一个常见的错误。

这意味着您的应用程序的 JVM 在垃圾收集器上花费了太多时间 运行。它通常发生是因为 space 中有 接近 运行,并且 GC 必须越来越频繁地 运行 才能继续。

Additionally, cpu is very high when I working in the application(99%).

这是意料之中的;见上文。

I think that it is connected with xmx.

是的,它与此有关。

一种可能是您的 webapp 正在执行的任务需要比 -xmx 设置允许的更多的内存。增加 -xmx 将解决问题……直到您完成更大的任务。那时你需要看看你是否可以优化内存使用,或者购买一台内存更大的机器。 (你银行里有多少钱?)

另一种可能是你的webapp有内存泄漏。如果那是问题,那么增加 -xmx 并不能解决问题。您的 webapp 可能会再次 运行 进入 OOME ......尽管它可能需要更长的时间才能发生。

我建议您找到并阅读一篇关于修复内存泄漏的好文章。假设它是泄漏......直到你找到明确的证据证明它不是。

So how can I check the xmx size set for this application?

这取决于您如何运行安装 springboot 应用程序。例如,本文解释了如何使用嵌入式 Tomcat.

  • How can I configure the heap size when starting a Spring Boot application with embedded Tomcat?