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: 82
HashMap with 123456='Hello': 167
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



Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications
 
Submitted comments will be subject to moderation before being displayed.
 

About

My name is Mike Haller and I'm a software developer and architect at Bosch Software Innovations in Germany. I love programming, playing games and reading books. I like good food, making photos and learning and mentoring about the craftsmanship of commercial software development. Stack Overflow profile for mhaller

Quicksearch