Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2125

Bits: reading ints and longs is allocating unnecessary memory

    Details

    • Type: Enhancement
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 4.0
    • Labels:

      Description

      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.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                belaban Bela Ban
                Reporter:
                belaban Bela Ban
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: