>> The objects I send from one side to the other are always "new" so
>> there should
>> be no difference in using writeUnshared and writeObject...


There probably is some time cost (albeit small) associated with writeObject 
managing the back-references.  More importantly, using writeUnshared will save 
you from a significant memory problem.  If you use writeObject and your objects 
are many and all new, you will need to periodically call reset() (or 
close/re-open the object stream) or you will eventually run out of memory.

>
> This can only be true if the class consists of primitive types (so no
> Strings). Is it?

If I understand your question, then the answer is no.  There still will be a 
difference even if the object is just primitives, because the primitive values 
are not written to the stream using writeObject after the first write (where 
they will be with writeUnshared).  It's the top-level object (the one 
containing all of the primitives) that is cached using writeObject, not (only) 
the internal objects.  




Reply via email to