Java Object Serialization payload
Posted by Mike Haller
on Thursday, July 19. 2007
at 17:27
in Java
In distributed systems, you will probably move a lot of Object forth and back between your systems.
Some developers never even though about the actual data sizes being transmitted in these cases.
To get a rough feeling about the data transferred when using RMI, think about the following figures:
A class file like Serializable.class takes up 41 bytes.
An empty String only uses 7 bytes.
A BigDecimal is one of the fattes: 293 bytes
In fact, Strings are the most space-saving data type you can use for remoting.
Here is a list I compiled for your convenience.
Serializable.class: 41
Class without any properties: 51
Integer 123456: 81
Long 123456: 82
Empty String: 7
String 'Hello World': 18
Char Array 'Hello World': 49
Byte Array 'Hello World': 38
BigDecimal 123456: 293
Empty HashMap
HashMap
Primitive boolean true: 47
Complex type Boolean.TRUE: 47
Enum RoundingMode.CEILING: 82
Class with 6 properties, all null: 185
Class with 6 properties, default values: 525
Class with 6 properties, with 'real' data: 635
Class with 7 properties, all properties null: 243
Class with 7 properties, all properties default values: 587
Class with 7 properties, all properties with 'real' Data: 746
List of 100 same instancec: 1295
List of 100 deep copies: 25847
