Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TierStatistics.getOccupiedByteSize() for EntryUnit.ENTRIES sized caches #2500

Closed
unb opened this issue Oct 15, 2018 · 1 comment

Comments

@unb
Copy link

unb commented Oct 15, 2018

(Originally from this thread: https://groups.google.com/d/msg/ehcache-users/V82PvoA7wUI/J4x8HOjIBAAJ )

In Ehcache 3.6,1, for heap-based caches sized with EntryUnit.ENTRIES, calling TierStatistics.getOccupiedByteSize() returns -1 rather than the actually memory size.
This is because memory size is not tracked for ENTRIES limited caches.
In Ehcache 2.x, it was supported using cache.calculateInMemorySize().

The workaround is to use SizeOf.deepSizeOf() on the cache instance, but this requires internal knowledge of the cache (see https://groups.google.com/d/msg/ehcache-users/V82PvoA7wUI/vELd7FRKBQAJ )

To avoid this, please provide support to calculate the memory size on demand when TierStatistics.getOccupiedByteSize() is invoked for an ENTRIES limited cache.

@chrisdennis
Copy link
Member

chrisdennis commented Nov 16, 2022

The ever increasing complexity of sizing operations in later JDK versions make this unlikely to ever be implemented. Most users (who aren't jumping through hoops to make byte based sizing work) will never be able to have a functional version of this method. Closing for now since this may never get implemented. Feel free to lobby the JDK guys on https://bugs.openjdk.org/browse/JDK-8249196. If that issue ever makes progress then this feature may be more practical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants