• Patch
  • Status: Open
  • 2 Major
  • Resolution:
  • ehcache-core
  • tedwon
  • Reporter: tedwon
  • October 13, 2011
  • 0
  • Watchers: 2
  • November 08, 2011

Attachments

Description

It would be good if ehcache support to monitor how much memory cache is using currently.

For example it could be something like below,

* Adding methods in related Classes.

h3. net.sf.ehcache.Statistics

...
    public long getInMemorySizeInBytes() {
          return cache.calculateInMemorySize();
    }

h3. net.sf.ehcache.management.CacheStatistics

...
    public long getInMemorySizeInBytes() {
        updateIfNeeded();

        return statistics.getInMemorySizeInBytes();

    }

h3. net.sf.ehcache.management.CacheStatisticsMBean

...
long getInMemorySizeInBytes();

Comments

Fiona OShea 2011-10-25

Ted are you trying to find the OnHeapMemory Size?

Ted Won 2011-11-01

Hi Fiona O’Shea,

I mean it is for monitoring memory usage size in bytes for Cache.

Fiona OShea 2011-11-08

There are two usages of memory in Ehcache OnHeap and OffHeap Are you asking for the total between the two? Or one or the other? If one or the other, please specify which. thanks

Ted Won 2011-11-08

It’s OnHeap. This is for maxBytesLocalHeap cache attribute.

http://www.ehcache.org/documentation/user-guide/configuration#memory-based-cache-sizing-ehcache-25-and-higher

With ehcache.xml description * maxBytesLocalHeap - optional setting that constraints the memory usage of the Caches managed by the CacheManager to use at most the specified number of bytes of the local VM’s heap. * maxBytesLocalOffHeap - optional setting that constraints the offHeap usage of the Caches managed by the CacheManager to use at most the specified number of bytes of the local VM’s offHeap memory. * maxBytesLocalDisk - optional setting that constraints the disk usage of the Caches managed by the CacheManager to use at most the specified number of bytes of the local disk.

\

So I understand that like below * maxBytesLocalHeap ==> OnHeap * maxBytesLocalOffHeap ==> OffHeap

Thanks