Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protobuf-net Serialize/Deserialize to/from byte arrays

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?

like image 317
Superman Avatar asked Jun 20 '14 14:06

Superman


1 Answers

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.

like image 160
Dean Ward Avatar answered Oct 12 '22 09:10

Dean Ward