5

I am working in a GC sensitive environment, and am interested in serializing / deserializing protobuf from preallocated byte arrays instead of memory streams. Is this possible with the protobuf-net library?

Superman
  • 3,686
  • 6
  • 34
  • 46

1 Answers1

5

You can initialise a MemoryStream with a pre-allocated buffer, see this overload. You could probably go so far as to allocate one large buffer and index into bits of it using this overload.

You can then pass this stream to protobuf as usual.

Dean Ward
  • 4,793
  • 1
  • 29
  • 36