首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SpringBoot内存不足,无法运行Java运行时环境

SpringBoot内存不足,无法运行Java运行时环境
EN

Stack Overflow用户
提问于 2021-05-31 22:10:27
回答 2查看 563关注 0票数 0

我在5个线程中执行了超过30000个REST请求(每个线程6,000个),在SpringBoot中运行在Tomcat之上的Swagger,在运行35分钟后得到下一个错误:

代码语言:javascript
复制
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 16384 bytes for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
#   JVM is running with Zero Based Compressed Oops mode in which the Java heap is
#     placed in the first 32GB address space. The Java Heap base address is the
#     maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
#     to set the Java Heap base and to place the Java Heap above 32GB virtual address.
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2985), pid=24780, tid=58785
#
# JRE version: OpenJDK Runtime Environment (11.0.11+9) (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
# Java VM: OpenJDK 64-Bit Server VM (11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)

Command Line: -Xverify:none -XX:TieredStopAtLevel=1 -Xms2g -Xmx10g com.CamelSpringBootApplication

Host: Common KVM processor, 16 cores, 28G, Ubuntu 20.04.2 LTS
Time: Mon May 31 15:40:22 2021 CEST elapsed time: 2122.252495 seconds (0d 0h 35m 22s)

我遗漏了一些信息,也不知道原因。我在哪里犯了错?到底是什么占用了这么多内存,我如何在运行时释放内存?

只有在重新启动虚拟机后,内存才会恢复到64 VM。在我再次启动SpringBoot应用程序后,内存甚至在运行REST请求之前就开始下降。我需要支持尽可能多的REST请求,保留内存并防止SpringBoot应用程序崩溃。

更新:

这些是收集的堆转储的结果。我已经在heaphero.io中加载了heapdump.bin。我将感谢任何基于此结果的提示。

EN

回答 2

Stack Overflow用户

发布于 2021-06-01 12:04:52

这只是一个危险的猜测,在计算了大约30000个垃圾收集数量的四分之一之后,你可能超过了垃圾收集,调用System.gc();来通知垃圾收集。This i wrote位于内存中,需要一个小的垃圾管理检查和计数器。

票数 0
EN

Stack Overflow用户

发布于 2021-06-01 15:59:40

我希望你已经分配了足够的堆大小,即使你的Linux机器有64 GB的RAM,你也需要根据应用程序的传入流量从外部扩展它的默认容量。

您可以在pom.xml文件中增加spring boot应用程序的堆大小,如下所示:

代码语言:javascript
复制
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <jvmArguments>-Xmx4096m</jvmArguments>
    </configuration>
</plugin>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67775360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档