LRU byte Cache java
<p>I need to implement a cache in java with a maximum size, would like to do it using the real size of the cache in the memory and not the number of elements in the cache. This cache will basically have String as key and String as value. I have already implemented the cache using the LinkedHashMap structure of java but the question is how to know the actual size of the cache so that i can adapt the policy to drop an object when the size is too big.</p>

<p>Wanted to compute it using the getObjectSize() of the instrumentation package but it seems not working as desired.</p>

<p>When I do getObjectSize( a string ) whatever the size of the string is, it returns the same size : 32. I guess it's just using the reference size of the string or something like that and not the content. So don't know how to solve this problem efficiently. </p>

<p>Do you have any ideas ? </p>

<p>Thanks a lot!</p>
