[jboss-jira] [JBoss JIRA] (JGRP-2125) Bits: reading ints and longs is allocating unnecessary memory

Bela Ban (JIRA) issues at jboss.org
Fri Nov 4 10:00:00 EDT 2016


Bela Ban created JGRP-2125:
------------------------------

             Summary: 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
             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.




--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list