protected int computeExpandedBufferSize(final int size, int length, int remain) {
        int expandedBufferSize = 0;
        while (remain < size) {
            length <<= 1;
            expandedBufferSize = length;
            remain = expandedBufferSize - offset;
        }
        return expandedBufferSize;
    }
Buffer that can be expanded automatically
@author emeroad
commons-buffer/src/main/java/com/navercorp/pinpoint/common/buffer/AutomaticBuffer.java