]
Bela Ban updated JGRP-2125:
---------------------------
Labels: Beta3 (was: )
Bits: reading ints and longs is allocating unnecessary memory
-------------------------------------------------------------
Key: JGRP-2125
URL:
https://issues.jboss.org/browse/JGRP-2125
Project: JGroups
Issue Type: Enhancement
Reporter: Bela Ban
Assignee: Bela Ban
Priority: Minor
Labels: Beta3
Fix For: 4.0
Some readXXX() methods in Bits such as readLong(), readInt(), readLongSequence(),
readLongCompressed() etc read the length byte first, then create a byte[] array based on
it, read the required bytes into that array and finally call makeInt()/makeLong() etc.
The creation of the temp byte[] array is unnecessary and leads to unneeded memory
allocation, especially as quite a number of frequently used headers (e.g. NakAckHeader2,
UnicastHeader3 etc) do this.
SOLUTION: read the required bytes directly from the input (e.g. java.nio.ByteBuffer or
DataInput) and apply them to the result one-by-one, then return the result.