[#2339] Reduce memory usage in ProtobufVarint32LengthFieldPrepender

Motivation:

Reduce memory usage in ProtobufVarint32LengthFieldPrepender.

Modifications:

Explicit set the buffer size that is needed for the header (between 1 and 5 bytes).

Result:

Less memory usage in ProtobufVarint32LengthFieldPrepender.
This commit is contained in:
Alexey Diomin 2014-03-24 18:36:54 +03:00 committed by Norman Maurer
parent 68670ba195
commit ab2119feac

View File

@ -47,7 +47,7 @@ public class ProtobufVarint32LengthFieldPrepender extends MessageToByteEncoder<B
out.ensureWritable(headerLen + bodyLen);
CodedOutputStream headerOut =
CodedOutputStream.newInstance(new ByteBufOutputStream(out));
CodedOutputStream.newInstance(new ByteBufOutputStream(out), headerLen);
headerOut.writeRawVarint32(bodyLen);
headerOut.flush();