code: public void compact() {
      if (prev == this) throw new IllegalStateException();
      if (!prev.owner) return; // Cannot compact: prev isn't writable.
      int byteCount = limit - pos;
      int availableByteCount = SIZE - prev.limit + (prev.shared ? 0 : prev.pos);
      if (byteCount > availableByteCount) return; // Cannot compact: not enough writable space.
      writeTo(prev, byteCount);
      pop();
      SegmentPool.recycle(this);
    }
docs: Call this when the tail and its predecessor may both be less than half
  full. This will copy data so that segments can be recycled.