ZeroFormatter icon indicating copy to clipboard operation
ZeroFormatter copied to clipboard

Issue when serialize and deserialize object list

Open MarcoGuzzetti opened this issue 8 years ago • 6 comments

Hi, I'm using successfully the formatter in my project, but I have an issue: if i serialize an object like this:

public class Ob { public List<CustomObject> List {get;set;} }

all seems fine. When I deserialize the object, I can see in the debugger window that the List type isn't CustomObject but instead a ZeroFormatter object (seems fine).

I can add and remove elements from list, but when I add only one element and then I try to serialize the object again, I can see the size of the serialized object was increased considerably (twice compared to first object).

Why? How can I resolve this?

Thank you

MarcoGuzzetti avatar Jun 16 '17 10:06 MarcoGuzzetti

Seeing similar behavior. We ZeroFormatterSerializer.Serialize() objects into redis. Deserializing those bytes easily doubles the size of the object. Still trying to determine why. This is catastrophic when updating the same entity multiple times, and each update increases the serialization.

cluedtke avatar Dec 11 '17 04:12 cluedtke

me too. any solution?

robertvo avatar Jan 02 '18 05:01 robertvo

@robertvo, what I did was deep clone object before re-serializing. It's more of a hack, but it definitely keeps object size down.

cluedtke avatar Jan 02 '18 13:01 cluedtke

Yeah, thank you, but that's not going to work, I have like 1mil of objects :(

robertvo avatar Jan 02 '18 16:01 robertvo

I experience the same problem. This makes ZeroFormatter useless. Is there any plan to fix this?

lucjanl avatar Mar 16 '18 13:03 lucjanl

Hi, I experience the same with a Dictionary<string, MyClass> in an Unity project. Can someone give me hints about deep cloning this kind of collection? Dictionary<string, MyClass> copy = new Dictionary<string, MyClass>(original); Doesn't seem to work.

[edit] Nevermind, I think I found how to: by simply recreating a fresh new dic by adding fresh new string key and fresh new Myclass value from each entry in the deserialized dic. this alternative to the bug will do the job for me as a "read from disk>deserialize>update dic>reserialize>write on disk" takes a mere 5s for approx. 100k entries dic.

So annoying little thing, this serializer is a pure gem otherwise...

Skizomeuh avatar Apr 13 '18 13:04 Skizomeuh