I think this would be too complicated to integrate into the official C++
implementation.  You could, however, write an alternative protobuf
implementation that provides this.

Note that with the official implementation, you can avoid malloc costs by
reusing message objects.  A message object never frees any memory until the
top-level object is destroyed, so if you reuse the object to parse multiple
messages, you can avoid a lot of allocation costs after the first message.

You might also experiment with tcmalloc (part of the Google perftools
package) to see if it is faster than your system's memory allocator.

On Wed, Dec 29, 2010 at 10:21 PM, aristohuang <pmp...@gmail.com> wrote:

> eg.
> message A {
>    string a; when set_a(), memory of a in heap(new/malloc)
>    int b; when set_b(), memory of b in stack
> };
>
> if defines many composite sub-class objects, a lot of time cost in new/
> malloc. are you think so? or have a good idear for this?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to