Context: after the upgrade of java to java 1.8.0_281 the application failed to start. In the java code, I am trying to allocate some memory for an offheap cache, defined like this:
<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>
But I am receiving the following error at startup:
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)
(......more stack trace here.... If needed, I will provide it)
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]
(....)
It is very weird to see 0B physical memory, because from what I've checked, the linux server where the app runs have plenty memory. I read that in most cases, the swapped memory is connected to off-heap memory. So my first idea of solving this issue was to increase the swap memory, because at first it was 0. But after doing that and restart the server, the error was still there.
Command used: free
Result:
total used free shared buffers cached
Mem: 30221268 27787476 2433792 546780 344464 22443644
-/+ buffers/cache: 4999368 25221900
Swap: 1023996 0 1023996
Another mention, on another linux server, that uses the same java version, the application works and starts well.
Am I missing something? Why do I get that error? What could I check more?
Any help is welcomed.