0
votes

I'm using ehcache 2.8.2 (migrated from 1.6.2) on a large reporting application. Due to out of memory errors, I'm changing the configuration from being bounded by the number of elements (maxElementsInMemory) to being bounded to heap memory (maxBytesLocalHeap/maxBytesLocalDisk) on the cacheManager level . Unfortunately, this is not working very well.

The application has around 100 caches (one for each report). This makes it convenient to manage the caches separately. However, when using a maxBytes configuration to pool the heap space between the caches, each cache only takes 1/100 of the pool. The application would have around 5 or 6 caches in use at a given moment, so this constraint is massively inefficient in our case.

What we would like to do is to have maxBytesLocalHeap as the limit size of all caches, but each cache could take the amount of memory it needs, without being bounded to 1/100 of the size of the pool (Perhaps using LRU across caches). Of course, the sum of the size of all caches should be smaller than the pool.

Is this possible to do with ehcache? What alternatives would you suggest in this case?

1
How extensively are you using the features of EhCache? If it is limited to get(K) and put(K, V), you could perhaps create a single cache of caches. Each element in this single_cache would be <cache_type, local_cache> - TJ-

1 Answers

0
votes

You could try monitoring free memory in your vm and adapting EhCache CacheInstance CacheConfigurations respectively. Reduce them when less memory and increase when more memory.