How to serialize large nested arrays with protobuf?

I am using protobuf-net for binary serialization. I gettig OutOfMemory when serializing class A. The same object serializes well with BinaryFormatter.

The following is an example class:

[ProtoContract] class A: [ProtoMember(1, DataFormat = DataFormat.Group)] B[] Array1 {get; set;} .... class B: [ProtoMember(1)] string Field1 {get; set;} [ProtoMember(2)] string Field1 {get; set;} [ProtoMember(3, DataFormat = DataFormat.Group)] C[] Array2 {get; set;} // 20000 elements .... class C: [ProtoMember(1)] string Field1 {get; set;} [ProtoMember(2)] string Field1 {get; set;} 
+4
source share
1 answer

Wow. Just wow. Thanks for asking this question. There was a failure because it misused group coding in several scenarios, including yours. For protobuf-net, this is not a biggie, since the group and the line are processed interchangeably, but it is still a bit embarrassing failure, not least because the "group" (as you used correctly) makes the key forward, only for serializing large graphs.

I fixed it locally and in the source, however I want to do a little more stable testing before making the official version. If you are happy to build from the source code, now it should work fine - or I can send you a dll if you want.

+4
source

Source: https://habr.com/ru/post/1416543/


All Articles