gourav dhiman gourav dhiman - 17 days ago 8
Java Question

How to get the used amount of memory of heap in EHcache?

Actually i want to know the occupied memory by cache. It will give me the element count in the size not the used space. So how to get it??

Answer

The getStatistics() method of net.sf.ehcache.Cache will give the information of used memory in bytes.

StatisticsGateway stats = cache.getStatistics();
stats.getLocalHeapSizeInBytes();
Comments