C
caultonpos
Hi,
I keep a local cache of objects for performance reasons and pull
objects from that cache instead of the server. The Swing client has a
configuration to how much memory is allocated for that cache.
If those objects are modified the cache is not updated (for a number
of reasons).
Currently I get the object from the server and use a byte stream to
make a copy of the object which is placed in the cache. I can use the
byte array size to determine the memory allocated to the object.
ByteArrayOutputStream byteArray = new
java.io.ByteArrayOutputStream(defaultByteArraySize);
out = new ObjectOutputStream(byteArray);
out.writeObject(o);
return byteArray.toByteArray();
When I need the object from the cache I deserialize from the bytes
bis = new ByteArrayInputStream(bytes);
in = new ObjectInputStream(bis);
Object o = in.readObject();
Is this the fastest way to make a (true) copy and then retrieve the
copy (while staying within a fix size of memory)?
thanks!
Greg
I keep a local cache of objects for performance reasons and pull
objects from that cache instead of the server. The Swing client has a
configuration to how much memory is allocated for that cache.
If those objects are modified the cache is not updated (for a number
of reasons).
Currently I get the object from the server and use a byte stream to
make a copy of the object which is placed in the cache. I can use the
byte array size to determine the memory allocated to the object.
ByteArrayOutputStream byteArray = new
java.io.ByteArrayOutputStream(defaultByteArraySize);
out = new ObjectOutputStream(byteArray);
out.writeObject(o);
return byteArray.toByteArray();
When I need the object from the cache I deserialize from the bytes
bis = new ByteArrayInputStream(bytes);
in = new ObjectInputStream(bis);
Object o = in.readObject();
Is this the fastest way to make a (true) copy and then retrieve the
copy (while staying within a fix size of memory)?
thanks!
Greg