System.out.println(testCache.get("1") == null); System.out.println(testCache.getSize()); System.out.println(testCache.getStatistics().getLocalHeapSizeInBytes()); System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M"); System.out.println(testCache.get("2") == null); System.out.println(testCache.getSize()); System.out.println(testCache.getStatistics().getLocalHeapSizeInBytes()); System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M"); System.out.println(testCache.get("3") == null); System.out.println(testCache.getSize()); System.out.println(testCache.getStatistics().getLocalHeapSizeInBytes()); System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M");
/** * Warning: This method can be very expensive to run. Allow approximately 1 second * per 1MB of entries. Running this method could create liveness problems * because the object lock is held for a long period * <p> * * @return the approximate size of memory ehcache is using for the MemoryStore for this cache */ public final long getSizeInMemory() { try { return cache.getStatistics().getLocalHeapSizeInBytes(); } catch (Throwable t) { return -1; } }
/** * Gets the size of the memory store for this cache. This method relies on calculating * Serialized sizes. If the Element values are not Serializable they will show as zero. * <p> * Warning: This method can be very expensive to run. Allow approximately 1 second * per 1MB of entries. Running this method could create liveness problems * because the object lock is held for a long period * * @return the approximate size of the memory store in bytes * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE} */ @Deprecated public final long calculateInMemorySize() throws IllegalStateException, CacheException { checkStatus(); return getStatistics().getLocalHeapSizeInBytes(); }
/** * {@inheritDoc} */ @Override public long getLocalHeapSizeInBytes() { try { return cache.getStatistics().getLocalHeapSizeInBytes(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
@Override public Long get() { return stats.getLocalHeapSizeInBytes(); } };
StatisticsGateway stats = cache.getStatistics(); stats.getLocalHeapSizeInBytes();
/** * Warning: This method can be very expensive to run. Allow approximately 1 second * per 1MB of entries. Running this method could create liveness problems * because the object lock is held for a long period * <p/> * * @return the approximate size of memory ehcache is using for the MemoryStore for this cache */ public final long getSizeInMemory() { try { return cache.getStatistics().getLocalHeapSizeInBytes(); } catch (Throwable t) { return -1; } }
/** * Warning: This method can be very expensive to run. Allow approximately 1 second * per 1MB of entries. Running this method could create liveness problems * because the object lock is held for a long period * <p> * * @return the approximate size of memory ehcache is using for the MemoryStore for this cache */ public final long getSizeInMemory() { try { return cache.getStatistics().getLocalHeapSizeInBytes(); } catch (Throwable t) { return -1; } }
} else { final long inMemorySizeInBytes = overflowToOffHeap ? cache.getStatistics().getLocalOffHeapSizeInBytes() : cache.getStatistics() .getLocalHeapSizeInBytes(); final long avgSize = inMemorySizeInBytes / inMemoryCount;
/** * Gets the size of the memory store for this cache. This method relies on calculating * Serialized sizes. If the Element values are not Serializable they will show as zero. * <p> * Warning: This method can be very expensive to run. Allow approximately 1 second * per 1MB of entries. Running this method could create liveness problems * because the object lock is held for a long period * * @return the approximate size of the memory store in bytes * @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE} */ @Deprecated public final long calculateInMemorySize() throws IllegalStateException, CacheException { checkStatus(); return getStatistics().getLocalHeapSizeInBytes(); }
/** * {@inheritDoc} */ @Override public long getLocalHeapSizeInBytes() { try { return cache.getStatistics().getLocalHeapSizeInBytes(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
/** * Gets the size of the memory store for this cache. This method relies on calculating * Serialized sizes. If the Element values are not Serializable they will show as zero. * <p/> * Warning: This method can be very expensive to run. Allow approximately 1 second * per 1MB of entries. Running this method could create liveness problems * because the object lock is held for a long period * <p/> * * @return the approximate size of the memory store in bytes * @throws IllegalStateException */ @Deprecated public final long calculateInMemorySize() throws IllegalStateException, CacheException { checkStatus(); return getStatistics().getLocalHeapSizeInBytes(); }
/** * {@inheritDoc} */ @Override public long getLocalHeapSizeInBytes() { try { return cache.getStatistics().getLocalHeapSizeInBytes(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
} else { final long inMemorySizeInBytes = overflowToOffHeap ? cache.getStatistics().getLocalOffHeapSizeInBytes() : cache.getStatistics() .getLocalHeapSizeInBytes(); final long avgSize = inMemorySizeInBytes / inMemoryCount;
} else { final long inMemorySizeInBytes = overflowToOffHeap ? cache.getStatistics().getLocalOffHeapSizeInBytes() : cache.getStatistics() .getLocalHeapSizeInBytes(); final long avgSize = inMemorySizeInBytes / inMemoryCount;