Re: [protobuf] Re: Memory not getting deallocated.

32 views
Skip to first unread message

Adam Cozzette

unread,
Mar 11, 2020, 12:21:27 PM3/11/20
to Gaurav sahil, Protocol Buffers
I think you have to destroy the message if you want its memory to be fully released. If I remember right, proto2 messages implement Clear() in a way that does not free submessages, and some projects have used this as an optimization. (You can Clear() and reuse the same message many times and avoid memory allocations.)

On Wed, Mar 11, 2020 at 3:09 AM Gaurav sahil <sahilg...@gmail.com> wrote:
Please find the link aswell,


On Wednesday, March 11, 2020 at 3:36:39 PM UTC+5:30, Gaurav sahil wrote:
Google Protocol Buffer Version - 3.5.x

Usage - Using it to share data between and embeded system and cloud.

Issue - After packetizing the data we use ParentMessage->Clear(); function to clear the data. This function is not reducing the memory allocated. 
Checked in Google Protocol buffer documentation that the memory allocated by new is internally being allocated statically. 
What  does statically mean ? Will the memory be available statically even after clear. ?


--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/7a55044e-a44a-497d-ac02-d35800f2c084%40googlegroups.com.

Gaurav sahil

unread,
Mar 12, 2020, 1:05:19 PM3/12/20
to Protocol Buffers
I feel Google protobuff is also using a memory pool internally.(placement NEW maybe) so once we clear(), it assigns the same memory to a new object. We analyzed the memory usage in smaps and observed that after reaching a particular memory threshold it doesn't increase further.

I am curious is there a way to reduce this threshold maybe? Or some other way to delete the memory.

Actually we have a multithreaded application. Each thread useses protobuff object to serialize the data.
So we cant wait for one thread to complete its clear(). All this have to be done simultaneously.

Reply all
Reply to author
Forward
0 new messages