Protobuf.net:OutOfMemoryException

时间:2014-08-30 00:58:00

标签: protobuf-net

我在FileStream上调用Serializer.Deserialize时遇到System.OutOfMemoryException。这仅发生在一个特定文件上,而不是任何其他文件。任何想法为什么会这样?所有文件都具有相似的大小,并且都包含相似的数据,使用相同的方法进行序列化。

代码(对不起VB代码 - 这不是我的选择)

Dim loadObj As Object = Nothing Using tempStream As FileStream = File.OpenRead(dataFilename) loadObj = Serializer.Deserialize(Of MeterReadingsByMeterId)(tempStream) 'fails on 724 every time If Not loadObj.GetType() Is GetType(MeterReadingsByMeterId) Then loadObj = Nothing End If End Using

堆栈追踪:

Exception of type 'System.OutOfMemoryException' was thrown. at System.Collections.Generic.Dictionary`2.Resize() at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add(KeyValuePair`2 keyValuePair) at proto_6(Object , ProtoReader ) at ProtoBuf.Serializers.CompiledSerializer.ProtoBuf.Serializers.IProtoSerializer.Read(Object value, ProtoReader source) at ProtoBuf.Meta.RuntimeTypeModel.Deserialize(Int32 key, Object value, ProtoReader source) at ProtoBuf.ProtoReader.ReadTypedObject(Object value, Int32 key, ProtoReader reader, Type type) at ProtoBuf.ProtoReader.ReadObject(Object value, Int32 key, ProtoReader reader) at proto_4(Object , ProtoReader ) at ProtoBuf.Serializers.CompiledSerializer.ProtoBuf.Serializers.IProtoSerializer.Read(Object value, ProtoReader source) at ProtoBuf.Meta.RuntimeTypeModel.Deserialize(Int32 key, Object value, ProtoReader source) at ProtoBuf.ProtoReader.ReadTypedObject(Object value, Int32 key, ProtoReader reader, Type type) at ProtoBuf.ProtoReader.ReadObject(Object value, Int32 key, ProtoReader reader) at proto_2(Object , ProtoReader ) at ProtoBuf.Serializers.CompiledSerializer.ProtoBuf.Serializers.IProtoSerializer.Read(Object value, ProtoReader source) at ProtoBuf.Meta.RuntimeTypeModel.Deserialize(Int32 key, Object value, ProtoReader source) at ProtoBuf.Meta.TypeModel.DeserializeCore(ProtoReader reader, Type type, Object value, Boolean noAutoCreate) at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type type, SerializationContext context) at ProtoBuf.Serializer.Deserialize[T](Stream source)

0 个答案:

没有答案