program size increse when use ParseFromArray for non-ordinary protobuf messages

22 views
Skip to first unread message

Dmitry Gorelov

unread,
Dec 12, 2023, 10:43:36 AM12/12/23
to Protocol Buffers
Hello!
I met a  problem of size increase of my program written in C++.

During investigation I came to a simple piece of code, incapsulated in a {} block, where:
- I create a protobuf message, fill it in with some dummy values.
- get size by calling msg.ByteSizeLong(),
- serialize msg to array of chars allocated to size  I got on previous step.
- Immediatelly I call ParseFromArray of another protobuf message of the same type, using same array and size as data source.
- And exit from the code block.

If the number of objects (either repeated or map<>) in the message is big enough, I see that the size of a program grows and never gets smaller.
If repeated the call of block 10 times, or more, the program size gets noticeable big.
I expect that the protobuf message objects do clear used memory at the moment when program exits the {} block from message destructor.
But this does not happen.

Reply all
Reply to author
Forward
0 new messages