Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-713

IoBufferHexDumper.getHexdump() over-allocates memory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.0-M5
    • 2.0.0-M6
    • Core
    • None

    Description

      hey folks. in IoBufferHexDumper.getHexdump(), we see this:

              boolean truncate = in.remaining() > lengthLimit;
              int size;
              if (truncate) {
                  size = lengthLimit;
              } else {
                  size = in.remaining();
              }
      
              if (size == 0) {
                  return "empty";
              }
      
              StringBuilder out = new StringBuilder(in.remaining() * 3 - 1);
      

      note that the allocation uses in.remaining(), even though it'll only
      insert the number of items indicated by "size". If the buffer is
      particularly large, this is unnecessary and wasteful of memory.

      Attachments

        1. p
          0.4 kB
          Justin Mason

        Activity

          People

            elecharny Emmanuel Lécharny
            jm Justin Mason
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: