I want to have a quite exact measurement of my cache implemented in java. Please tell me if this approach is possible.
I have a hashmap mapping a string to an array of string. Is there some way to get a good aproximation of this data structure?
How do I get the size of a string? Call String.toByte() and add some plus for the overhead of holding the object?
Is a string array the sum of all strings? Or is there some overhead?
Does the hashmap also have some overead, maybe wrapping the objects into some entry object?
For all unused space in the map, the hashmap still allocates some space, can I sum up 2 * null pointer for all unsused spaces in the map?
I'm happy with partical answers aswell poiting me in the right direction.
I think a good practical approach is to use a memory profiler such as YourKit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With