read, write Objects via Sockets

R

Roedy Green

But that isn't an argument against caching per se, which could have
been implemented to detect when a sent object doesn't agree with the
cached one.

I guess you could just use equals for that determination.

The trouble is equals would often not detect a changed field.

But I suppose programmers could live with that, implementing equals if
it really mattered. Perhaps a new interface would be needed so you
would not disturb equals semantics.

In most cases you really want the current value of all objects
transmitted. The way it is now is an unfortunate accident of the
implementation.

It amazing that RPC works at all sitting atop a mechanism that does
not track changes.
 
L

Lasse Reichstein Nielsen

Arne Vajhøj said:
In real life I would expect a java.util.LinkedList to be send in
a single writeObject and I will assume that it would work fine.

The point was, I guess, to give an example of a cyclic data structure.

The "caching" feature of ObjectInputStream is really not about
caching, it's just nessecitated by ObjectOutputStream allowing
serialization of cyclic structures. Each object is only sent once,
and only received once.

If you send a data structure, or perhaps several of them, in one go,
the deserialization works as expected, and uses no more memory than
would be expected.

If you use the *same* Object{Output,Input}Stream to end objects as
part of different communication sessions, i.e., where something might
have happened to the objects in between, at either end, you *should*
reset the streams between sessions. Any "caching" that might occour
is most likely not what you want anyway. It's *not* a performance
feature.

/L
 
T

tricky

If you would search a little bit you would find thaht it's reported as a bug
! on february 2007 ! but it's not resovled yet
 
T

tricky

I can send you a profiler view if you want :D.
The most importent thing for me is that i can avoid it by using different
methods
 
E

Esmond Pitt

tricky said:
If you would search a little bit you would find thaht it's reported as a bug
! on february 2007 ! but it's not resovled yet

If you had searched a little more carefully you would have seen that bug
concerns a memory leak *at the sender* and *when you use
writeUnshared(). What is being discussed here is a possible memory leak
*at the receiver* when using readObject(). Nothing to do with it.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top