I've got a strange behaviour when using a message with a repeated
This is a very simplified example:
required bytes content = 1;
required bytes sender = 2;
required bytes rcpt = 3;
repeated Input entries = 1;
google::protobuf::RepeatedPtrField<Input>* entries =
std::auto_ptr<Input> in = createInputEntry();
std::string serialized = in->SerializeAsString();
Input* entry = response.add_entries();
std::string serializedResponse = response.SerializeAsString();
The createInputEntry and serialization does not make in this example
any sense, but it is a simplified scenario what happens in the real
I was expecting that when Response is out of scope the memory usage
should get back to the initial memory size, but unfortunately this
does not happen. In my test case (it is not the initial size is around
2MB, after inserting some entries it increases up to 9MB and the
memory is not released.
The behaviour changes in case I resize the pointer array to lets say
10000 in this example. After Response is out of scope the memory usage
is the same as at the beginning. But If I reserve more than entries
are created the inital behaviour comes back.
I am not totally sure what happens at that point. Maybe someone could
explain this strange behaviour.
Thanks in advance.
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to
For more options, visit this group at