I use EhCache with a memory cache loaded from a disk cache.
When dumping the JVM of my process, I noticed that EhCache stored in memory the cache and the diskstore object of that cache.
The memory size of both is getting big (DiskStore in memory is around 75% of the memory cache).
I am wondering why the DiskStore is on disk and in memory, in addition to the normal memory cache ?
The Cache caches data in memory for speed of access. You have to load the data into memory to use it and it is a very bad idea to remove it from disk just because its in memory.
Saving disks resources is a waste of time in this case as disk space is relative cheap and changing it is relatively expensive.