std::bad_alloc comes from your system's memory allocator, not from protocol buffers. I would guess that the round number is because it creates buckets for each allocation size, and you aren't allocating anything else that is the same size as B. So 0x1000000 is your system's bucket limit.
You could try using tcmalloc (Google's memory allocator) instead. http://code.google.com/p/google-perftools/ Alternatively, if message B only has a single int32 field, then you could also try changing message A like: message A { repeated int32 b = 1 [packed=true]; } This would be far more efficient, both in memory and on the wire. On Thu, Aug 26, 2010 at 9:34 AM, Louis Marascio <maras...@gmail.com> wrote: > Hi there, I have a simple message defined with a repeated field. The > repeated field type is another message type. For example: > > Message A { > repeated B b = 1; > } > > Message B { > required uint32 x = 1; > } > > I'm building up a single A message in memory with quite a few B's. I > am constantly receveiving a std::bad_alloc exception while trying to > allocate the 16777217 or 0x1000001 'th msg. This number seems oddly > round. > > Is there some builtin limit to the number of repeated values a > repeated field may contain? > > Thanks, > > Louis > > -- > 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<protobuf%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > -- 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.