问题描述
上下文:在java升级到java 1.8.0_281之后,应用程序启动失败。 在java代码中,我试图为堆外缓存分配一些内存,定义如下:
<cache-template name="myCache">
<expiry>
<none/>
</expiry>
<resources>
<heap unit="entries">100000</heap>
<offheap unit="MB">256</offheap>
<disk unit="MB">1000</disk>
</resources>
</cache-template>
但我在启动时收到以下错误:
Caused by: java.lang.IllegalStateException: Cache 'myCache' creation in EhcacheManager Failed.
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:302)
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:252)
at org.ehcache.jsr107.Eh107CacheManager.createCache(Eh107CacheManager.java:201)
(......这里有更多堆栈跟踪......如果需要,我会提供)
Caused by: org.ehcache.StateTransitionException: Attempting to allocate 256MB of memory when the host only contains 0B of physical memory
at org.ehcache.core.StatusTransitioner$Transition.succeeded(StatusTransitioner.java:209)
at org.ehcache.core.EhcacheBase.init(EhcacheBase.java:569)
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:275)
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:252)
at org.ehcache.jsr107.Eh107CacheManager.createCache(Eh107CacheManager.java:201) ~[ehcache-3.9.0.jar:3.9.0 97b6a73ef8644dc028234f166c90f951f60f099b]
(....)
看到0B物理内存很奇怪,因为根据我的检查,运行应用程序的linux服务器有足够的内存。 我读到在大多数情况下,交换的内存连接到堆外内存。所以我解决这个问题的第一个想法是增加交换内存,因为一开始它是0。但是这样做并重新启动服务器后,错误仍然存在。
使用的命令:free
结果:
total used free shared buffers cached
Mem: 30221268 27787476 2433792 546780 344464 22443644
-/+ buffers/cache: 4999368 25221900
Swap: 1023996 0 1023996
另外提到,在另一台使用相同 java 版本的 linux 服务器上,应用程序运行良好,启动良好。
我错过了什么吗?为什么我会收到那个错误?我还能检查什么?
欢迎任何帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)