[#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 844362a947
commit 2a4999b6b8

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();