Is there a way of estimating (roughly) in memory object size from Serialized object size in Java
In some cases, the secondary intention of data serialization is to minimize the data's size which then reduces disk space or bandwidth requirements.
Serialization offers a plethora of benefits. Some of its primary advantages are: Used for marshaling (traveling the state of an object on the network) To persist or save an object's state.
Compact serialization is also binary serialization but NCache provides a lot more flexibility with this serialization framework. Compact serialization does not reduce the size of the entire data, it instead only reduces the size of the data that is travelled over the network.
Minimum object size is 16 bytes for modern 64-bit JDK since the object has 12-byte header, padded to a multiple of 8 bytes. In 32-bit JDK, the overhead is 8 bytes, padded to a multiple of 4 bytes.
The size in memory will be usually between half and double the serializable size. The most extreme example might be the Byte which is more than 80 bytes Serialized can be 16 bytes in memory.
You can use a profiler to tell you how much memory an object uses. Another way is to use a tool based on Instrumentation.getObjectSize(object)
You might find this interesting Getting the size of an Object
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