Hey

I just found out a way to optimize the use of MarshalledObject, if it's 
used to send stuff over the network (JBoss has it's own version, but it 
has the same basic code).

The MO serializes the data into a ByteArrayOutputStream, which then is 
toByteArray'ed in order to get the data. This is bad, since the data is 
then copied into a new array of the same length. This may not mean much, 
but if you're doing it all the time it makes a difference.

There's a trick to get around this: simply store the BAOS in an instance 
variable of the MO, and call out.write(BAOS.size());BAOS.writeTo(out); 
during serialization. This will avoid the copy. Read the data during 
deserialization, and the rest is the same.

This simple trick will hence reduce the number of byte arrays created by 
50%. You'll probably want to introduce this fix into MarshalledValue, 
and any other place where MO's are used.

/Rickard

-- 
Rickard Öberg
[EMAIL PROTECTED]
Senselogic

Got blog? I do. http://dreambean.com



-------------------------------------------------------
This sf.net email is sponsored by: Dice - The leading online job board
for high-tech professionals. Search and apply for tech jobs today!
http://seeker.dice.com/seeker.epl?rel_code1
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to