I think what you want is lazy parsing, which unfortunately isn't available
yet.  You could always read bytes off the stream in chunks, or write your
own CodedInputStream to skip to the end of each message every time it sees a
length.

Alek

On Fri, Jul 17, 2009 at 8:13 PM, Alex Black <a...@alexblack.ca> wrote:

>
> When I write out messages using C++ I'm careful to clear messages and
> re-use them, is there something equivalent on the java side when
> reading those same messages in?
>
> My code looks like:
>
> CodedInputStream stream = CodedInputStream.newInstance(inputStream);
>
> while ( !stream.isAtEnd() )
> {
>     MyMessage.Builder builder = MyMessage.newBuilder();
>     stream.readMessage(builder, null);
>     MyMessage myMessage = builder.build();
>
>     for ( MessageValue messageValue : myMessage.getValuesList() )
>     {
>        ......
>     }
> }
>
> I'm passing 150 messages each with 1000 items, so presumably memory is
> allocated 150 times for each of the messages...
>
> - Alex
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@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