doubt about serialization

Discussion in 'Java' started by chandu, Feb 25, 2006.

  1. chandu

    chandu Guest

    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
     
    chandu, Feb 25, 2006
    #1
    1. Advertising

  2. chandu wrote:
    > 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.

    --
    John Bollinger
     
    John C. Bollinger, Feb 25, 2006
    #2
    1. Advertising

  3. chandu

    Kevin Guest

    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.
     
    Kevin, Feb 25, 2006
    #3
  4. chandu

    Timo Stamm Guest

    Kevin schrieb:
    > 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
     
    Timo Stamm, Feb 25, 2006
    #4
  5. Kevin wrote:
    > 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.)

    --
    John Bollinger
     
    John C. Bollinger, Feb 26, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    2,306
    deadsea
    Jan 2, 2005
  2. Replies:
    3
    Views:
    1,084
  3. Dimitri Ognibene
    Replies:
    4
    Views:
    820
    Dimitri Ognibene
    Sep 2, 2006
  4. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    659
  5. Ramunas Urbonas
    Replies:
    1
    Views:
    426
    Dino Chiesa [Microsoft]
    Jul 27, 2004
Loading...

Share This Page