doubt about serialization

C

chandu

why objects are to be serialized ,when we want to put them on
stream.cont we pass them as byte by byte as other types
 
J

John C. Bollinger

chandu said:
why objects are to be serialized ,when we want to put them on
stream.cont we pass them as byte by byte as other types

That's more or less what serialization is. Java's built-in
serialization does have some very nice additional behavior when it comes
to objects that hold references to other, shared objects, however, in
that the deserialized versions refer to one common copy of the original
instead of to different ones. That can in fact be very important for
correctness. The built-in serialization mechanism also handles all the
details automatically, for any Serializable type, so that you don't have
to write custom serialization code for most types of object you want to
transfer.
 
K

Kevin

But if I remember it well, it will be very slow if there are many
reference among the objects. Java will check the reference among the
objects and write that information out as well.
In one project, I ended up writing my own code for that, which speeded
up 10x.
 
T

Timo Stamm

Kevin said:
But if I remember it well, it will be very slow if there are many
reference among the objects. Java will check the reference among the
objects and write that information out as well.
In one project, I ended up writing my own code for that, which speeded
up 10x.

You can use the transient attribute for members that are cheap to
rebuild, but expensive to serialize.


Timo
 
J

John C. Bollinger

Kevin said:
But if I remember it well, it will be very slow if there are many
reference among the objects. Java will check the reference among the
objects and write that information out as well.
In one project, I ended up writing my own code for that, which speeded
up 10x.

Naturally, if you can make use of knowledge about the details of the
objects being serialized then there is opportunity to improve on the
speed of Java's built-in mechanism. On the other hand, I have trouble
believing that you achieved across-the-board 1000% speedup for general
serializable objects, if indeed your method was generally applicable at
all. (Assuming always that it worked correctly in the first place; I'm
sure you're satisfied that it did.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top