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

Bits: reading ints and longs is allocating unnecessary memory

    XMLWordPrintable

Details

    • Enhancement
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Done
    • None
    • 4.0

    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.

      Attachments

        Activity

          People

            rhn-engineering-bban Bela Ban
            rhn-engineering-bban Bela Ban
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: