将spring Boot 应用程序部署到云铸造厂失败,并出现JVM内存问题

wfveoks0  于 2022-11-07  发布在  Spring
关注(0)|答案(1)|浏览(242)

将Sping Boot 应用程序部署到Pivotal Cloud Foundry失败,并出现以下错误。示例的限制设置为2GB,然后设置为4GB。本地应用程序在2GB堆大小的情况下启动良好。应用程序该高速缓存管理器初始化期间失败。您知道根本原因是什么吗?不确定Terracotta在Cloud Foundry中扮演什么角色,还需要查找什么?

2019-05-07T19:24:53.39+0530 [APP/PROC/WEB/0] OUT     at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
   2019-05-07T19:24:53.39+0530 [APP/PROC/WEB/0] OUT Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'cacheManager' threw exception; nested exception is org.ehcache.StateTransitionException: Cache '<name hidden>' creation in EhcacheManager failed.
....
 Caused by: java.lang.IllegalArgumentException: An attempt was made to allocate more off-heap memory than the JVM can allow. The limit on off-heap memory size is given by the -XX:MaxDirectMemorySize command (or equivalent).
   2019-05-07T19:15:13.15+0530 [APP/PROC/WEB/0] OUT     at org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource.bufferAllocation(UpfrontAllocatingPageSource.java:564)
   2019-05-07T19:15:13.15+0530 [APP/PROC/WEB/0] OUT     at org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource.lambda$allocateBackingBuffers$1(UpfrontAllocatingPageSource.java:513)
   2019-05-07T19:15:13.15+0530 [APP/PROC/WEB/0] OUT     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   2019-05-07T19:15:13.15+0530 [APP/PROC/WEB/0] OUT     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   2019-05-07T19:15:13.15+0530 [APP/PROC/WEB/0] OUT     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   2019

编辑:****已修复通过删除堆外ehcache配置:最大字节数本地堆外

lrl1mhuk

lrl1mhuk1#

默认情况下,Java构建包会限制JVM的不同内存区域,这样可以确保Java应用程序不会超过容器的内存限制,否则会导致应用程序崩溃。
您的应用程序试图创建的直接内存量超过了Java构建包设置的限制。在我写这篇文章时,Java构建包设置为-XX:MaxDirectMemorySize=10M
要实现这一点,您只需在manifest.yml中或使用cf set-env设置一个环境变量,名为JAVA_OPTS,内容需要包括-XX:MaxDirectMemorySize=XXM,其中XX是您要使用的较大值。
Java构建包将看到您何时调整内存设置,并将减少其他内存区域的大小以进行补偿。如果您试图使用大量直接内存,这可能会导致其他区域没有足够的内存。如果发生这种情况,您需要增加应用程序的整体内存限制。
https://github.com/cloudfoundry/java-buildpack/blob/master/docs/jre-open_jdk_jre.md#java-options
希望这对你有帮助!

相关问题